473,569 Members | 2,729 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 7897
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
49664
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(). Instead one has to iterate through the string, parse all UTF-8 multibytes and count each multibyte as one character. To address this problem the...
4
3157
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 database using unicode compression field (for ancient language). I would like to export this table into MySQL o Postgres, but it's
1
1791
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 within the export. I am certain that this should be remedied by changin the charset and/or encoding, but I cannot seem to get it right. // Set up...
6
13879
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 character in streamreader and streamwriter. How unicode and utf chacters are stored.
6
8548
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 DataAccess.StoredProcedure("sproc_getdata"); sproc.Run(dt);
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 DataAccess.StoredProcedure("sproc_getdata"); sproc.Run(dt);
2
16442
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 still see all the arabic text OK with no problem, but if I open the CSV file in Microsoft EXCEL, all the arabic text are busted and no longer...
3
6530
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 failed too. (but with different import results): import from xy.csv of del modified by coldel; replace into tmp If I do the same statement with...
1
9532
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 db2move export command from the db2 client on Windows XP. However, when I import the data into the target schema, I noticed some special characters...
1
1642
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 "+ADw-html" instead of "<html". please give me alternative solution so document can open in word 2000-03-07 version. .
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.