473,503 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RTF export: UTF-8 to ANSI conversion?

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. Of course non-Latin-1 characters would go lost.
Trying to understand the RTF spec I found that ISO-8859-1 is not
available in RTF, but only the Windows 1252 codepage which differs from
Latin-1 in some characters.

So I set the codepage to 1252 and learned that characters not contained
in this codepage should be placed as Unicode:

<quote>
For example, the text Lab[Gamma]Value (Unicode characters 0x004c,
0x0061, 0x0062, 0x0393, 0x0056, 0x0061, 0x006c, 0x0075, 0x0065) should
be represented as follows (assuming a previous \ucl):

Lab\u915Gvalue
</quote>

Now I don't understand this anymore... What does the G after the decimal
value mean? How should this \ucl be applied? ...

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)
- Can somebody point me to an easy to understand RTF tutorial?

Thanks for any hint!
Markus
Jul 3 '07 #1
1 7882
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

--
Wiktor Walc
http://phpfreelancer.net/en
Freelance PHP Developer
Jul 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
49649
by: Wolfgang Draxinger | last post by:
I understand that it is perfectly possible to store UTF-8 strings in a std::string, however doing so can cause some implicaions. E.g. you can't count the amount of characters by length() | size()....
4
3152
by: JJ | last post by:
Hi, usually, I'm not using MS servers, but I have a big problem with a Access table. I should create a web application for a Historical Dipartment. They have created a populated a Access...
1
1788
by: Webmills | last post by:
Hi I am exporting a datagrid to Excel using the code as below. The problem that I am experiencing is that if my datagrid includes &nbsp; characters, spurious A with an accent characters appear...
6
13875
by: archana | last post by:
Hi all, can someone tell me difference between unicode and utf 8 or utf 18 and which one is supporting more character set. whic i should use to support character ucs-2. I want to use ucs-2...
6
8544
by: elangovan.cse | last post by:
Hi all, I'm exporting a datagrid to an excel file. I'm using the following source code to export. DataTable dt = new DataTable(); DataAccess.StoredProcedure sproc = new...
1
312
by: elangovan.cse | last post by:
Hi all, I'm exporting a datagrid to an excel file. I'm using the following source code to export. DataTable dt = new DataTable(); DataAccess.StoredProcedure sproc = new...
2
16401
by: farukcse | last post by:
Dear Sir, I have a PHP script that export CSV with arabic text, for example I download the CSV on the website then save to desktop of my computer and Open it on NOTEPAD... that works fine I could...
3
6520
by: Stefan | last post by:
Hi, When I import data from an CSV file, data seems to be converted (into iso-8851-1 ???) although the csv data and the db are in utf-8 format. I also tried "modified by codepage=1208" but it...
1
9503
by: tong_su | last post by:
Hi, I am using udb version 8 fixpack 12 installed on Linux. I need to move a schema from one db to another. All tables in the target and source schemas are created using 'CCSID UNICODE'. I used...
1
1634
by: =?Utf-8?B?VWp2YWwgU2hhaA==?= | last post by:
Hi, I am creating word document using UTF-7 in ASP.Net 2.0. so till the date, word document is opening perfactly in Word 2000 and word 2003. but in Word 2007, It show encoded text also like...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.