nik1004
nik1004

Reputation: 337

Iconv byte length

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?

Upvotes: 0

Views: 895

Answers (1)

user4035
user4035

Reputation: 23769

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

Upvotes: 1

Related Questions