This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Problems with Unicode characters, when I use this API Rtf.Template Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Problems with Unicode characters, when I use this API Rtf.Template" Watch "Problems with Unicode characters, when I use this API Rtf.Template" New topic
Author

Problems with Unicode characters, when I use this API Rtf.Template

Maiko Cezar
Greenhorn

Joined: Apr 03, 2009
Posts: 3
Hi I'm using this API http://rtftemplate.sourceforge.net/#New%20API and it is working very well, but when I finished my project I discover an issue, the writer function what I'm using does not support characters like this à ã é í...
Anyone already had use this API to write RTF documents? How can I resolve this?

The download of this API can be done at this link:
http://sourceforge.net/project/downloading.php?group_id=153424&use_mirror=ufpr&filename=rtftemplate-1.0.1-b14-src.zip&a=77764145

that is a example code:


The RTF Source
Name: $NAME
City: $CITY

The RTF Target after the execution
Name: Maiko Cezar
City: São Paulo

If anyone can help me with this problem, I'll be very grateful, because my project are done but lack resolve this issue, and the time is short to be delivered.


BB

ps: sorry my english.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Sounds like it's an encoding problem (I actually moved this to the Open Source forum too quickly).

OK, you need to make sure that your program writes the files out in the encoding expected (UTf-8 or whatever). Your reader (Notepad or whatever) needs to be able to _read_ those characters as well, you might be legitimately writing out the correct characters but your client reader and/or your OS may not support those characters.

So

1.) Make sure you're using the right method calls to write the encoded string. So check the API to see if you can pass in the correct encoding required.
2.) Make sure RTF supports that encoding (remember its a limited text format compared to say a MS Word doc), I'm pretty sure this should be OK though.
3.) Make sure your OS/Client Reader can read the correct encoding. You can test this by getting your program to write the characters directly to the console and/or IDE console and compare that against what your client reader can see (be aware that your console/IDE console also need to be able to read that encoding).


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Maiko Cezar
Greenhorn

Joined: Apr 03, 2009
Posts: 3
Hi,

I have one question, how can I be sure to check my SO and applications, if they can read/writer correctly ? I'm using Ubuntu 8.1 and netbeans 6.5, and to open the RTF files, Writer and Kate.

I did one modification in my code to do that. (I guess)


my output
São Paulo
São Paulo

And then I put this (São Paulo) in the rtfTarget, but without successful. The "ISO-8859-1" encode it's the rtf native encode, isn't?

bb
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi there,

See here for details on RTF character encoding, it looks like its 8-bit ASCII by default with the ability to display unicode extensions. That should help you choose the encoding you need.
Maiko Cezar
Greenhorn

Joined: Apr 03, 2009
Posts: 3
Hi,

Thanks for who have tried to help me. I sent a email to Rtf.Template author, and he answer me with the link to the official forum (no have any reference in the official site), http://sourceforge.net/forum/forum.php?forum_id=513003 I have solved my problem with this function


thanks for all.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Interesting! As the wikipedia article suggests, there needed to be a conversion to unicode, glad you were able to solve it!
 
wood burning stoves
 
subject: Problems with Unicode characters, when I use this API Rtf.Template