Skip to content

Commit

Permalink
Merge pull request #168 from apache/XALANJ-2618
Browse files Browse the repository at this point in the history
Improved encoding lookup
  • Loading branch information
jkesselm authored Jan 27, 2024
2 parents 289dd5f + 1aad64a commit d83b90e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
/**
* Provides information about encodings. Depends on the Java runtime
* to provides writers for the different encodings.
*
* NOTE: When a Java or MIME names appears more than once in the
* encodings.properties table, priority is given to the first instance
* seen. For example, MIME name ISO-8859-1 will be mapped to Java name
* ISO8859-1, even though the file includes synonyms such as ISO8859_1
* and 8859-1.
* <p>
* This class is not a public API. It is only public because it
* is used outside of this package.
Expand Down Expand Up @@ -369,9 +375,9 @@ private static EncodingInfo[] loadEncodingInfo()
mimeName = st.nextToken();
EncodingInfo ei = new EncodingInfo(mimeName, javaName, highChar);
encodingInfo_list.add(ei);
_encodingTableKeyMime.put(mimeName.toUpperCase(), ei);
_encodingTableKeyMime.putIfAbsent(mimeName.toUpperCase(), ei);
if (first)
_encodingTableKeyJava.put(javaName.toUpperCase(), ei);
_encodingTableKeyJava.putIfAbsent(javaName.toUpperCase(), ei);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
# Higher values above this char might be in the encoding, although in the
# case of this particular encoding there are no higher chars.
#
# NOTE: When a Java or MIME names appears more than once in this
# table, priority is given to the first instance seen. For example,
# MIME name ISO-8859-1 will be mapped to Java name ISO8859-1.
#
# <JAVA name encoding>, <PREFERRED name MIME>
#
Expand Down

0 comments on commit d83b90e

Please sign in to comment.