in reply to UTF8 to UTF16, but...
(Note how the Encode module puts the BOM in for you automatically when you tell it to create "UTF-16" data, as opposed to "UTF-16[LB]E", which will not get an automatic BOM included.)perl -MEncode -le '$str="\x{0442}\x{0435}\x{0441}\x{0442}"; $sms=unpack("H*",encode("UTF-16",$str)); print $sms' #prints: feff0442043504410442
You just need to make sure about what is really being requested -- if the BOM screws things up, and almut's guess about it being big-endian turns out to be wrong, then it must be little-endian ("UTF-16LE").
It can be remarkably easy for this to be a matter of confusion -- many folks are not accustomed to being as specific as they should be when describing their unicode needs, and some tools for viewing wide-character byte sequences may give you a distorted view.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF8 to UTF16, but...
by almut (Canon) on Dec 12, 2008 at 02:32 UTC | |
by graff (Chancellor) on Dec 12, 2008 at 04:20 UTC |