.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "NetSDS::Util::String 3pm" .TH NetSDS::Util::String 3pm "2011-08-27" "perl v5.12.4" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" NetSDS::Util::String \- string prcessing routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use NetSDS::Util::String qw(); \& \& # Read from standard input \& my $string = ; \& \& # Encode string to internal structure \& $string = string_encode($tring); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`NetSDS::Util::String\*(C'\fR module contains functions may be used to quickly solve string processing tasks like parsing, recoding, formatting. .PP As in other NetSDS modules standard encoding is \s-1UTF\-8\s0. .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" .ie n .IP "\fBstr_encode($str[, \fB$encoding\fB])\fR \- encode string to internal \s-1UTF\-8\s0" 4 .el .IP "\fBstr_encode($str[, \f(CB$encoding\fB])\fR \- encode string to internal \s-1UTF\-8\s0" 4 .IX Item "str_encode($str[, $encoding]) - encode string to internal UTF-8" By default this function treat first argument as byte string in \s-1UTF\-8\s0 and return it's internal Unicode representation. .Sp In case of external character set isn't \s-1UTF\-8\s0 it should be added as second argument of function. .Sp .Vb 2 \& # 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, \*(AqKOI8\-U\*(Aq); .Ve .Sp After \f(CW\*(C`str_encode()\*(C'\fR it's possible to process this string correctly including regular expressions. All characters will be understood as \s-1UTF\-8\s0 symbols instead of byte sequences. .ie n .IP "\fBstr_decode($str[, \fB$encoding\fB])\fR \- decode internal \s-1UTF\-8\s0 to byte string" 4 .el .IP "\fBstr_decode($str[, \f(CB$encoding\fB])\fR \- decode internal \s-1UTF\-8\s0 to byte string" 4 .IX Item "str_decode($str[, $encoding]) - decode internal UTF-8 to byte string" By default this function treat first argument as string in internal \s-1UTF\-8\s0 and return it in byte string (external) representation. .Sp In case of external character set isn't \s-1UTF\-8\s0 it should be added as second argument of function. .Sp .Vb 2 \& # 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, \*(AqKOI8\-U\*(Aq); .Ve .Sp It's recommended to use \f(CW\*(C`str_encode()\*(C'\fR when preparing data for communication with external systems (especially networking). .ie n .IP "\fBstr_recode($str, \fB$FROM_ENC\fB[, \f(BI$TO_ENC\fB])\fR \- recode string" 4 .el .IP "\fBstr_recode($str, \f(CB$FROM_ENC\fB[, \f(CB$TO_ENC\fB])\fR \- recode string" 4 .IX Item "str_recode($str, $FROM_ENC[, $TO_ENC]) - recode string" Translate string between different encodings. If target encoding is not set \s-1UTF\-8\s0 used as default one. .IP "\fBstr_trim($str)\fR \- remove leading/trailing space characters" 4 .IX Item "str_trim($str) - remove leading/trailing space characters" .Vb 2 \& $orig_str = " string with spaces "; \& $new_str = str_trim($orig_str); \& \& # Output: "string with spaces" \& print $new_str; .Ve .IP "\fBstr_trim_left($str)\fR \- removes leading whitespaces" 4 .IX Item "str_trim_left($str) - removes leading whitespaces" This function is similar to \f(CW\*(C`str_trim()\*(C'\fR except of it removes only leading space characters and leave trailing ones. .IP "\fBstr_trim_right($str)\fR \- removes trailing whitespaces" 4 .IX Item "str_trim_right($str) - removes trailing whitespaces" This function is similar to \f(CW\*(C`str_trim()\*(C'\fR except of it removes only trailing space characters and leave leading ones. .IP "\fBstr_clean($str)\fR \- clean string from extra spaces" 4 .IX Item "str_clean($str) - clean string from extra spaces" Function is similar to \f(CW\*(C`str_trim()\*(C'\fR but also changes all spacing chains inside string to single spaces. .IP "\fBstr_camelize($strin)\fR" 4 .IX Item "str_camelize($strin)" If pass undef \- return undef. If pass '' \- return ''. .Sp Examples: .Sp .Vb 2 \& # returns \*(AqgetValue\*(Aq \& str_camelize( \*(Aqget_value\*(Aq ) \& \& # returns \*(AqaddUserAction\*(Aq \& str_camelize( \*(AqADD_User_actION\*(Aq ) .Ve .IP "\fBstr_decamelize(...)\fR" 4 .IX Item "str_decamelize(...)" If pass undef \- return undef. If pass '' \- return ''. .Sp Examples: .Sp .Vb 2 \& # returns \*(Aqget_value\*(Aq \& str_decamelize( \*(AqgetValue\*(Aq ) .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" None yet .SH "BUGS" .IX Header "BUGS" Unknown yet .SH "TODO" .IX Header "TODO" Implement examples and tests. .SH "SEE ALSO" .IX Header "SEE ALSO" Encode, perlunicode .SH "AUTHORS" .IX Header "AUTHORS" Valentyn Solomko .PP Michael Bochkaryov