0

I am using iconv to convert string from CP1251 to UTF-8 Problem is that string length before conversion is 4 bytes, after 8.

After converting i send message to Apple servers, where is length is limited.

How I can get conversion and keep the same length?

SheetJS
  • 22,470
  • 12
  • 65
  • 75
nik1004
  • 327
  • 3
  • 11

1 Answers1

1

There is no way you can do it. In UTF-8 one-byte codes are used only for the ASCII values 0 through 127. In this case the UTF-8 code has the same value as the ASCII code. The high-order bit of these codes is always 0.

As you are trying to encode non-ASCII characters, you'll get more, then 1 byte per character.

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets

http://en.wikipedia.org/wiki/UTF-8#Overlong_encodings

user4035
  • 22,508
  • 11
  • 59
  • 94