Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: SWT app UTF8 problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SWT app UTF8 problem



sam wrote:

That's actually the quick and clean solution! Nowadays, in almost all
cases you want to ensure a full UTF-8 workflow with all byte stream
input/output; unfortunately, on most platforms that isn't the default in
Java, which means that you need to always specify UTF-8 on every
class/constructor that has a 'character encoding' parameter.


Some time ago, I started using a class that had factory methods, one for each type of object (FileReader, InputStreamReader, String, etc.) that relied on a text-encoding. Then everywhere you'd use the constructor that specifies an encoding name, call the factory method in the utility class. This falls under Don't Repeat Yourself. It also makes it easy to change the encoding in one place, such as for testing. It's too bad the "file.encoding" property doesn't cut it, but it is what it is.

There's only about a half-dozen or so different factory methods that any app actually uses. And new ones aren't that hard to write.

  -- GG

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.