>>>>> On Fri, 18 May 2007 10:26:41 -0700, Ryan Lubke <Ryan.Lubke_at_Sun.COM> said:
RL> Hey folks,
RL> I'm working on removing the following pending comments from
RL> c.s.f.util.HtmlUtils:
RL> // Double-byte characters to encode.
RL> // PENDING: when outputting to an encoding that
RL> // supports double-byte characters (UTF-8, for example),
RL> // we should not be encoding
RL> _writeDecRef(out, ch)
RL> I've come up with:
RL> /**
RL> * @param encoding a valid encoding
RL> * @return <code>true</code> if the specified encoding is
RL> * multi-byte, otherwise <code>false</code>
RL> */
RL> static public boolean isEncodingMultiByte(String encoding) {
RL> Charset c = Charset.forName(encoding);
RL> return (c.newEncoder().maxBytesPerChar() > 1.0f);
RL> }
RL> Just curious if anyone had ideas on a better way to handle this detection.
How frequently will this be called? If frequently, consider caching the
result.
Ed
--
| ed.burns_at_sun.com | office: 408 884 9519 OR x31640
| homepage: | http://purl.oclc.org/NET/edburns/
| aim: edburns0sunw | iim: ed.burns_at_sun.com