diff options
author | Henrik Nord <[email protected]> | 2011-09-20 10:30:53 +0200 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2011-09-20 10:31:01 +0200 |
commit | 5b3f4c143cf7c9cd32437bfc9882f6ceb960648e (patch) | |
tree | 4972c2b892d5e179054c300899a3e9fd145140f4 /lib/xmerl/src/xmerl_ucs.erl | |
parent | 7973451a3c9fbdeef47a94ed45b65b59422abe57 (diff) | |
parent | 60c2511da7fb72197a807e77e62fdf671676e718 (diff) | |
download | otp-5b3f4c143cf7c9cd32437bfc9882f6ceb960648e.tar.gz otp-5b3f4c143cf7c9cd32437bfc9882f6ceb960648e.tar.bz2 otp-5b3f4c143cf7c9cd32437bfc9882f6ceb960648e.zip |
Merge branch 'dj/xmerl_ucs-latin9-support' into dev
* dj/xmerl_ucs-latin9-support:
Add latin9 (iso-8859-15) support in xmerl_ucs
OTP-9552
Diffstat (limited to 'lib/xmerl/src/xmerl_ucs.erl')
-rw-r--r-- | lib/xmerl/src/xmerl_ucs.erl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/xmerl/src/xmerl_ucs.erl b/lib/xmerl/src/xmerl_ucs.erl index 076595d873..feb16070a0 100644 --- a/lib/xmerl/src/xmerl_ucs.erl +++ b/lib/xmerl/src/xmerl_ucs.erl @@ -43,6 +43,7 @@ -export([to_utf16be/1, from_utf16be/1, from_utf16be/2]). -export([to_utf16le/1, from_utf16le/1, from_utf16le/2]). -export([to_utf8/1, from_utf8/1]). +-export([from_latin9/1]). %%% NB: Non-canonical UTF-8 encodings and incorrectly used %%% surrogate-pair codes are disallowed by this code. There are @@ -184,6 +185,20 @@ from_utf8(List) -> exit({ucs,{bad_utf8_character_code}}) end. +%%% Latin9 support +from_latin9(Bin) when is_binary(Bin) -> from_latin9(binary_to_list(Bin)); +from_latin9(List) -> + [ latin9_to_ucs4(Char) || Char <- List]. + +latin9_to_ucs4(16#A4) -> 16#20AC; +latin9_to_ucs4(16#A6) -> 16#160; +latin9_to_ucs4(16#A8) -> 16#161; +latin9_to_ucs4(16#B4) -> 16#17D; +latin9_to_ucs4(16#B8) -> 16#17E; +latin9_to_ucs4(16#BC) -> 16#152; +latin9_to_ucs4(16#BD) -> 16#153; +latin9_to_ucs4(16#BE) -> 16#178; +latin9_to_ucs4(Other) -> Other. @@ -476,6 +491,8 @@ to_unicode(Input,Cs) when Cs=='iso_8859-1:1987';Cs=='iso-ir-100'; Cs=='l1';Cs=='ibm819'; Cs=='cp819';Cs=='csisolatin1' -> Input; +to_unicode(Input,Cs) when Cs=='iso_8859-15';Cs=='iso-8859-15';Cs=='latin9' -> + from_latin9(Input); % to_unicode(Input,Cs) when Cs=='mnemonic';Cs=='"mnemonic+ascii+38'; % Cs=='mnem';Cs=='"mnemonic+ascii+8200' -> % from_mnemonic(Input); |