NetSDS...String(3pm)
β¨ NAME β¨
NetSDS::Util::String β string prcessing routines π
this is the NetSDS...String(3pm) page from User Contributed Perl Documentation, and she's here to help you do string stuff without losing your mind π«Ά
πΈ SYNOPSIS πΈ
use NetSDS::Util::String qw();
# Read from standard input
my $string = <STDIN>;
# Encode string to internal structure
$string = string_encode($tring);
π DESCRIPTION π
okay so "NetSDS::Util::String" is that module that comes in clutch when you need to handle string processing tasks quickly β think parsing, recoding, formatting. all the little text gremlins, handled β¨
and just like every other NetSDS module, the standard encoding is UTF-8. no cap, that's the vibe everywhere. π¦
π EXPORTED FUNCTIONS π
π str_encode($str[, $encoding]) β encode string to internal UTF-8
by default, this one takes the first argument as a byte string in UTF-8 and hands you back its internal Unicode representation. glow-up complete π
if the external character set is not UTF-8, you just pass it as the second argument, bestie.
# Convert UTF-8 byte string to internal Unicode representation
$uni_string = str_encode($byte_string);
# Convert KOI8-U byte string to internal
$uni_string = str_encode($koi8_string, 'KOI8-U');
after str_encode() you can actually process that string correctly, regular expressions and all. every character is understood as a UTF-8 symbol instead of a messy pile of byte sequences. it's giving competence π
π¦ str_decode($str[, $encoding]) β decode internal UTF-8 to byte string
by default, this one treats the first argument as a string in internal UTF-8 and returns it in byte string (external) representation. reverse glow-up, same energy π
if the external character set isn't UTF-8, add it as the second argument of the function.
# Get UTF-8 byte string from internal Unicode representation
$byte_string = str_decode($uni_string);
# Convert to KOI8-U byte string from internal Unicode
$koi8_string = str_encode($uni_string, 'KOI8-U');
fr fr, it's recommended to use str_encode() when you're preparing data to talk to external systems β especially networking. trust. π
π str_recode($str, $FROM_ENC[, $TO_ENC]) β recode string
translate a string between different encodings. if the target encoding isn't set, UTF-8 is used as the default one. slay, sensible defaults β¨
π§ str_trim($str) β remove leading/trailing space characters
$orig_str = " string with spaces ";
$new_str = str_trim($orig_str);
# Output: "string with spaces"
print $new_str;
π str_trim_left($str) β removes leading whitespaces
same vibe as "str_trim()", except it only removes the leading space characters and leaves the trailing ones alone. half the trim, all the drama π
π str_trim_right($str) β removes trailing whitespaces
same vibe as "str_trim()", except it only removes the trailing space characters and leaves the leading ones alone. mirror image, iconic πͺ
πΈ str_clean($str) β clean string from extra spaces
similar to "str_trim()" but also squishes all the spacing chains inside the string down to single spaces. interior design for your whitespace π§Ή
β str_camelize($strin)
if you pass undef β it returns undef. if you pass '' β it returns ''. consistent queen π
examples:
# returns 'getValue'
str_camelize( 'get_value' )
# returns 'addUserAction'
str_camelize( 'ADD_User_actION' )
π str_decamelize(...)
if you pass undef β it returns undef. if you pass '' β it returns ''. same rules, opposite direction π«
examples:
# returns 'get_value'
str_decamelize( 'getValue' )
π« EXAMPLES π«
None yet π
π BUGS π
Unknown yet π
π₯ TODO π₯
Implement examples and tests. (manifesting this for us β¨)
π SEE ALSO π
Encode, perlunicode
π«Ά AUTHORS π«Ά
Valentyn Solomko <pere@pere.org.ua>
Michael Bochkaryov <misha@rattler.kiev.ua>
and that's the whole page, bestie β written by the legends above, and this copy is running under perl v5.36.0 from 2022-11-20 π go forth and encode responsibly, mwah π
π¦ where this page comes from
- debian bookworm: libnetsds-util-perl 1.045-2 Β· GPL-2.0-or-later
- debian trixie: libnetsds-util-perl 1.045-2 Β· GPL-2.0-or-later
- ubuntu noble: libnetsds-util-perl 1.045-2 Β· GPL-2.0-or-later
- ubuntu questing: libnetsds-util-perl 1.045-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms