Posted by Markus on 07/12/07 15:45
iktorn schrieb:
> Markus napisał(a):
>> Hello
>>
>> I try to write RTF files using text in UTF-8 encoding. Converting the
>> text with utf8_decode() already fails on characters such as an
>> apostrophe or an endash.
>> So these are actually my questions:
>> - Is there a good way to convert an UTF-8 string into CP1252, without
>> losing the non-CP1252 character info? (mbstring is not available on
>> that server)
>
> You will always lose some characters wile converting utf-8 to encoding
> that can handle up to 255 chars.
>
> I haven't done anything related to RTF, but to convert UTF8 to CP-1252
> you can use iconv library:
> http://pl.php.net/manual/en/ref.iconv.php
>
> with optional //IGNORE and //TRANSLIT modifiers
>
Thank you! From my first look at iconv, //IGNORE will make it unlossy;
anyway there would be no way to identify the unconverted characters (in
order to convert them to RTF Unicode syntax).
Meantime I found a solution using PEAR I18N_UnicodeString:
http://pear.php.net/package/I18N_UnicodeString
This gives me an array of the decimal Unicode representations of all
characters; so I can convert every character individually.
[Back to original message]
|