From fdac46814401d78d2fe63db77b498f4d020795f4 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Mon, 6 Apr 2020 16:28:09 -0700 Subject: [PATCH 1/3] More locale cases --- source/shared/localization.hpp | 1 + source/shared/localizationimpl.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/source/shared/localization.hpp b/source/shared/localization.hpp index ec339d8c6..4f2df190e 100644 --- a/source/shared/localization.hpp +++ b/source/shared/localization.hpp @@ -247,6 +247,7 @@ inline UINT SystemLocale::MaxCharCchSize( UINT codepage ) switch ( codepage ) { case CP_UTF8: + case 54936: return 4; case 932: case 936: diff --git a/source/shared/localizationimpl.cpp b/source/shared/localizationimpl.cpp index 22cc8bf6c..f3ca7f5cb 100644 --- a/source/shared/localizationimpl.cpp +++ b/source/shared/localizationimpl.cpp @@ -77,6 +77,7 @@ const cp_iconv cp_iconv::g_cp_iconv[] = { { 1256, "CP1256" TRANSLIT }, { 1257, "CP1257" TRANSLIT }, { 1258, "CP1258" TRANSLIT }, + { 54936, "GB18030" TRANSLIT}, { CP_ISO8859_1, "ISO8859-1" TRANSLIT }, { CP_ISO8859_2, "ISO8859-2" TRANSLIT }, { CP_ISO8859_3, "ISO8859-3" TRANSLIT }, @@ -342,6 +343,11 @@ SystemLocale::SystemLocale( const char * localeName ) const LocaleCP lcpTable[] = { { "utf8", CP_UTF8 }, { "UTF-8", CP_UTF8 }, + { "BIG5", 950 }, + { "BIG5-HKSCS", 950 }, + { "gb18030", 54936 }, + { "gb2312", 936 }, + { "gbk", 936 }, CPxxx(1252), CPxxx(850), CPxxx(437), CPxxx(874), CPxxx(932), CPxxx(936), CPxxx(949), CPxxx(950), CPxxx(1250), CPxxx(1251), CPxxx(1253), CPxxx(1254), CPxxx(1255), CPxxx(1256), CPxxx(1257), CPxxx(1258), ISO8859(1), ISO8859(2), ISO8859(3), ISO8859(4), ISO8859(5), ISO8859(6), From 03e2d3ff987353dac81a9f7ed1146821c43079c8 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 14 Apr 2020 16:20:48 -0700 Subject: [PATCH 2/3] Added new ANSI tests for testing fr_FR locale --- Dockerfile-msphpsql | 1 + .../pdo_sqlsrv/pdo_ansi_locale_fr.phpt | 79 ++++++++++++++++ .../pdo_sqlsrv/skipif_unix_ansitests.inc | 16 ++++ .../sqlsrv/skipif_unix_ansitests.inc | 16 ++++ .../sqlsrv/sqlsrv_ansi_locale_fr.phpt | 93 +++++++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 test/functional/pdo_sqlsrv/pdo_ansi_locale_fr.phpt create mode 100644 test/functional/pdo_sqlsrv/skipif_unix_ansitests.inc create mode 100644 test/functional/sqlsrv/skipif_unix_ansitests.inc create mode 100644 test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt diff --git a/Dockerfile-msphpsql b/Dockerfile-msphpsql index 31eba77a1..477740a00 100644 --- a/Dockerfile-msphpsql +++ b/Dockerfile-msphpsql @@ -42,6 +42,7 @@ ENV PATH="/opt/mssql-tools/bin:${PATH}" # add locales for testing RUN sed -i 's/# en_US ISO-8859-1/en_US ISO-8859-1/g' /etc/locale.gen +RUN sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen RUN sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen RUN locale-gen diff --git a/test/functional/pdo_sqlsrv/pdo_ansi_locale_fr.phpt b/test/functional/pdo_sqlsrv/pdo_ansi_locale_fr.phpt new file mode 100644 index 000000000..d54790538 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ansi_locale_fr.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test another ANSI encoding fr_FR euro locale outside Windows +--DESCRIPTION-- +This file must be saved in ANSI encoding and the required locale must be present +--ENV-- +PHPT_EXEC=true +--SKIPIF-- + +--FILE-- +prepare($tsql); + + for ($i = 0; $i < count($inputs); $i++) { + $stmt->execute(array($i, $inputs[$i])); + } + } catch( PDOException $e ) { + echo "Failed to insert data\n"; + print_r( $e->getMessage() ); + } +} + +function dropTable($conn, $tableName) +{ + $tsql = "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'" . $tableName . "') AND type in (N'U')) DROP TABLE $tableName"; + $conn->exec($tsql); +} + +require_once('MsSetup.inc'); + +try { + $locale = 'fr_FR@euro'; + setlocale(LC_ALL, $locale); + + $conn = new PDO("sqlsrv:server = $server; database=$databaseName; driver=$driver", $uid, $pwd); + $conn->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM); + $tableName = "pdo_ansitest_FR"; + + dropTable($conn, $tableName); + + $tsql = "CREATE TABLE $tableName([id] [int] NOT NULL, [phrase] [varchar](50) NULL)"; + $conn->exec($tsql); + + $inputs = array("À tout à l'heure!", + "Je suis désolé.", + "À plus!", + " Je dois aller à l'école."); + + // Next, insert the strings + insertData($conn, $tableName, $inputs); + + // Next, fetch the strings + $tsql = "SELECT phrase FROM $tableName ORDER by id"; + $stmt = $conn->query($tsql); + + $results = $stmt->fetchAll(PDO::FETCH_NUM); + for ($i = 0; $i < count($inputs); $i++) { + if ($results[$i][0] !== $inputs[$i]) { + echo "Unexpected phrase retrieved:\n"; + var_dump($results[$i][0]); + } + } + + dropTable($conn, $tableName); + + unset($stmt); + unset($conn); +} catch (PDOException $e) { + print_r($e->getMessage()); +} + +echo "Done" . PHP_EOL; +?> +--EXPECT-- +Done diff --git a/test/functional/pdo_sqlsrv/skipif_unix_ansitests.inc b/test/functional/pdo_sqlsrv/skipif_unix_ansitests.inc new file mode 100644 index 000000000..8029c9a33 --- /dev/null +++ b/test/functional/pdo_sqlsrv/skipif_unix_ansitests.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/test/functional/sqlsrv/skipif_unix_ansitests.inc b/test/functional/sqlsrv/skipif_unix_ansitests.inc new file mode 100644 index 000000000..84d4776f7 --- /dev/null +++ b/test/functional/sqlsrv/skipif_unix_ansitests.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt b/test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt new file mode 100644 index 000000000..90ccc864c --- /dev/null +++ b/test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test another ansi encoding fr_FR euro locale outside Windows +--DESCRIPTION-- +This file must be saved in ANSI encoding and the required locale must be present +--ENV-- +PHPT_EXEC=true +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Done + From 660d8980c8da7150d69d89be823d99f8c80c029d Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 14 Apr 2020 16:56:16 -0700 Subject: [PATCH 3/3] Updated azure pipeline yml as well --- azure-pipelines.yml | 1 + test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4444203fe..23579eab0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -111,6 +111,7 @@ jobs: - script: | sudo sed -i 's/# en_US ISO-8859-1/en_US ISO-8859-1/g' /etc/locale.gen + sudo sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen sudo sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen sudo sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen sudo locale-gen diff --git a/test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt b/test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt index 90ccc864c..c8bd131f6 100644 --- a/test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt +++ b/test/functional/sqlsrv/sqlsrv_ansi_locale_fr.phpt @@ -41,7 +41,7 @@ function dropTable($conn, $tableName) require_once('MsSetup.inc'); -$tableName = "pdo_ansitest_FR"; +$tableName = "srv_ansitest_FR"; $locale = 'fr_FR@euro'; setlocale(LC_ALL, $locale);