Mercurial > octave
changeset 23559:c9852320f004
native2unicode.m, unicode2native.m: Fix tests on Windows (bug #49842).
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 23 Mar 2017 18:11:24 +0100 |
parents | 00b11cee2100 |
children | 66dc0ce97f2b |
files | scripts/strings/native2unicode.m scripts/strings/unicode2native.m |
diffstat | 2 files changed, 17 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/strings/native2unicode.m Wed Jun 07 12:46:34 2017 -0700 +++ b/scripts/strings/native2unicode.m Thu Mar 23 18:11:24 2017 +0100 @@ -23,10 +23,12 @@ ## ## The numbers in the vector @var{native_bytes} are rounded and clipped to ## integers between 0 and 255. This byte stream is then mapped into the -## codepage given by the string @var{codepage} and returned in the string +## code page given by the string @var{codepage} and returned in the string ## @var{utf8_str}. Octave uses UTF-8 as its internal encoding. -## The string @var{codepage} must be an identifier of a valid codepage. -## Examples for valid codepages are "ISO 8859-1", "Latin-1" or "Shift-JIS". +## The string @var{codepage} must be an identifier of a valid code page. +## Examples for valid code pages are "ISO-8859-1", "Shift-JIS", or "UTF-16". +## For a list of supported code pages, see: +## http://www.gnu.org/software/libiconv/ ## If @var{codepage} is omitted or empty, the system default codepage is used. ## ## If @var{native_bytes} is a string vector, it is returned as is. @@ -70,12 +72,12 @@ endfunction ## "ЄЅІЇЈЉЊ" -%!assert (double (native2unicode (164:170, 'ISO 8859-5')), +%!assert (double (native2unicode (164:170, 'ISO-8859-5')), %! [208 132 208 133 208 134 208 135 208 136 208 137 208 138]); -%!assert (double (native2unicode ([164:166 0 167:170], 'ISO 8859-5')), +## ["ЄЅІ" 0 "ЇЈЉЊ"] +%!assert (double (native2unicode ([164:166 0 167:170], 'ISO-8859-5')), %! [208 132 208 133 208 134 0 208 135 208 136 208 137 208 138]); -## ["ЄЅІ" 0 "ЇЈЉЊ"] %!assert (native2unicode ("foobar"), "foobar"); %!assert (double (native2unicode ([0 0 120.3 0 0 122.6 0 0])), %! [0 0 120 0 0 123 0 0]); @@ -85,4 +87,4 @@ %!error <CODEPAGE must be a string> native2unicode (164:170, 123) %!error <converting from codepage 'foo' to UTF-8> native2unicode (234, 'foo') %!error <Invalid call> native2unicode () -%!error <Invalid call> native2unicode (1, 'Latin-1', 'test') +%!error <Invalid call> native2unicode (1, 'ISO-8859-1', 'test')
--- a/scripts/strings/unicode2native.m Wed Jun 07 12:46:34 2017 -0700 +++ b/scripts/strings/unicode2native.m Thu Mar 23 18:11:24 2017 +0100 @@ -22,9 +22,11 @@ ## Convert UTF-8 string @var{utf8_str} to byte stream using @var{codepage}. ## ## The character vector @var{utf8_str} is converted to a byte stream -## @var{native_bytes} using the codepage given by @var{codepage}. -## The string @var{codepage} must be an identifier of a valid codepage. -## Examples for valid codepages are "ISO 8859-1", "Latin-1" or "Shift-JIS". +## @var{native_bytes} using the code page given by @var{codepage}. +## The string @var{codepage} must be an identifier of a valid code page. +## Examples for valid code pages are "ISO-8859-1", "Shift-JIS", or "UTF-16". +## For a list of supported code pages, see: +## http://www.gnu.org/software/libiconv/ ## If @var{codepage} is omitted or empty, the system default codepage is used. ## ## If any of the characters cannot be mapped into the codepage @var{codepage}, @@ -56,12 +58,12 @@ endfunction -%!assert (unicode2native ("ЄЅІЇЈЉЊ", "ISO 8859-5"), uint8 (164:170)); -%!assert (unicode2native (["ЄЅІ" 0 "ЇЈЉЊ"], "ISO 8859-5"), uint8 ([164:166 0 167:170])); +%!assert (unicode2native ("ЄЅІЇЈЉЊ", "ISO-8859-5"), uint8 (164:170)); +%!assert (unicode2native (["ЄЅІ" 0 "ЇЈЉЊ"], "ISO-8859-5"), uint8 ([164:166 0 167:170])); %!error <UTF8_STR must be a character vector> unicode2native (['ab'; 'cd']) %!error <UTF8_STR must be a character vector> unicode2native ({1 2 3 4}) %!error <CODEPAGE must be a string> unicode2native ('ЄЅІЇЈЉЊ', 123) %!error <converting from UTF-8 to codepage 'foo'> unicode2native ('a', 'foo') %!error <Invalid call> unicode2native () -%!error <Invalid call> unicode2native ('a', 'Latin-1', 'test') +%!error <Invalid call> unicode2native ('a', 'ISO-8859-1', 'test')