From b023f4827f317cf6f2b431b1617eb6a555855508 Mon Sep 17 00:00:00 2001 From: Ben McDonald <46734217+bmcdonald3@users.noreply.github.com> Date: Wed, 11 Jan 2023 10:47:31 -0700 Subject: [PATCH] Closes #2054: Fix iconv encoding for multi-byte characters and reenable tests (#2055) * Fix iconv encoding for multi-byte characters In the initial encoding implementation, the output buffer for calculating the buffer length was a `bytes` buffer and that was causing issues when an output character was a multi-byte UTF-8 character. To fix this, the `bytes` buffer has been switched to a `uint-8` array. * Re-enable IDNA tests --- src/Codecs.chpl | 2 +- tests/string_test.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Codecs.chpl b/src/Codecs.chpl index a0fb7229db..e9c33ee6b9 100644 --- a/src/Codecs.chpl +++ b/src/Codecs.chpl @@ -98,7 +98,7 @@ module Codecs { var inSize = (inBufSize): c_size_t; // TODO: this is probably worst way to allocate this - var chplRes:bytes = (" "*(inBufSize*4)); + var chplRes: [0..#(inBufSize*4)] uint(8) = 0x00; var origSize = chplRes.size; var outSize = chplRes.size: c_size_t; diff --git a/tests/string_test.py b/tests/string_test.py index e9fa1f817a..07cf97b170 100644 --- a/tests/string_test.py +++ b/tests/string_test.py @@ -639,7 +639,6 @@ def test_get_fixes(self): p = strings.get_suffixes(1, return_origins=False, proper=False) self.assertListEqual(["c", "d", "i"], p.to_list()) - @pytest.mark.skip(reason="Skipping until issue resolved.") def test_encoding(self): idna_strings = ak.array(['Bücher.example','ドメイン.テスト', 'домен.испытание', 'Königsgäßchen']) expected = ak.array(['xn--bcher-kva.example','xn--eckwd4c7c.xn--zckzah', 'xn--d1acufc.xn--80akhbyknj4f', 'xn--knigsgchen-b4a3dun']) @@ -666,7 +665,6 @@ def test_encoding(self): a3 = ak.random_strings_uniform(1, 10, UNIQUE, characters="printable") self.assertTrue((a3 == a3.encode('ascii').decode('ascii')).all()) - @pytest.mark.skip(reason="Skipping until issue resolved.") def test_idna_utf16(self): s = ak.array(['xn--mnchen-3ya', 'xn--zrich-kva', 'example.com'])