|
|
Regular expressions mit Perl |
Aus Wiki.csoft.at
|
URI encoding (RFC 2396) s/([^\w()'*~!.-])/sprintf '%%%02x', ord $1/eg; # encode
s/%([A-Fa-f\d]{2})/chr hex $1/eg; # decode
UTF8 encoding s/([\x80-\xFF])/chr(0xC0|ord($1)>>6).chr(0x80|ord($1)&0x3F)/eg; # Latin-1 to UTF8 s/([\xC0-\xDF])([\x80-\xBF])/chr(ord($1)<<6&0xC0|ord($2)&0x3F)/eg; # UTF8 to Latin-1
Weblinks |