The default encoding for the application is set to "UTF-8" (using -Dfile.encoding = UTF-8 at startup). When I use the String class method "getBytes (String charsetName)" with charset = "ISO-8859-1", it looks like StringCoding.encode finally uses the default encoding (UTF-8) instead of this one (ISO-8859 -1).
For some unknown reason, I can debug step by step using this method, but I cannot check the value of the internal elements (only parameters called arg0, arg1 ...)
In java 1.6.10 StringCoding.encode is written:
static byte[] encode(String charsetName, char[] ca, int off, int len) throws UnsupportedEncodingException { StringEncoder se = (StringEncoder)deref(encoder); String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; if ((se == null) || !(csn.equals(se.requestedCharsetName()) || csn.equals(se.charsetName()))) { se = null; try { Charset cs = lookupCharset(csn); if (cs != null) se = new StringEncoder(cs, csn); } catch (IllegalCharsetNameException x) {} if (se == null) throw new UnsupportedEncodingException (csn); set(encoder, se); } return se.encode(ca, off, len); }
With step-by-step debugging, I never enter the if block, and then a new StringEncoder with my ISO-8859-1 encoding is not created. Finally, the Charset.defaultCharset () method is called.
Any clues? thanks
source share