Encoding Problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2013 01:40 PM
I have a simple text file in Alfresco that has this content in it: “Generic Table Template”
I have this code:
The default encoding is showing up correctly as UTF-8
however, when I look at the written file I see this: ���Generic Table Template���
Any Ideas?
I have this code:
ContentReader reader = contentService.getReader(node, ContentModel.PROP_CONTENT); if(reader != null) { System.out.println("Writing File:"+filename); System.out.println("Default encoding:"+reader.getEncoding()); File f = new File(filename); reader.getContent(f); }
The default encoding is showing up correctly as UTF-8
however, when I look at the written file I see this: ���Generic Table Template���
Any Ideas?
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2013 06:08 PM
you don't appear to have posted any relevant code.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2013 08:07 PM
I am confused. I posted the entire method. I get a ContentReader from the content service, and then according to the API, the line
should write the content to a file. Which it does, it just messes up the encoding somehow, even though reader.getEncoding() properly returns UTF-8
reader.getContent(f);
should write the content to a file. Which it does, it just messes up the encoding somehow, even though reader.getEncoding() properly returns UTF-8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 06:14 AM
ops:
I suspect its a bug and its writing in O.S. default encoding not UTF-8. However I've checked the code and can't see a problem.
I suspect its a bug and its writing in O.S. default encoding not UTF-8. However I've checked the code and can't see a problem.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 06:26 AM
How are you "looking" at that file? With these sorts of problems I find it useful to use a "hex dump" utility so we can actually see the bytes that have been written.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2013 01:45 PM
YES! Default OS file encoding is the problem. (almost) It was a JVM problem. I simply added -Dfile.encoding=UTF-8 to the startup script and the code above works perfectly.
Thank you all
Thank you all