]> git.joonet.de Git - adminer.git/commitdiff
MS SQL: Prefix Unicode strings with 'N' so they are treated correctly
authorHyP3r <mail@andreas-fendt.de>
Fri, 18 Mar 2022 20:08:25 +0000 (21:08 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 19 Feb 2025 10:16:41 +0000 (11:16 +0100)
adminer/drivers/mssql.inc.php

index ae2cd5761cf2cf5e73b52eac60d452883faab50b..baa1b5b0cfbad99c1f80f6c454c2d2d5828daa12 100644 (file)
@@ -40,7 +40,8 @@ if (isset($_GET["mssql"])) {
                        }
 
                        function quote($string) {
-                               return "'" . str_replace("'", "''", $string) . "'";
+                               $unicode = strlen($string) != strlen(utf8_decode($string));
+                               return ($unicode ? "N" : "") . "'" . str_replace("'", "''", $string) . "'";
                        }
 
                        function select_db($database) {
@@ -163,7 +164,8 @@ if (isset($_GET["mssql"])) {
                        }
 
                        function quote($string) {
-                               return "'" . str_replace("'", "''", $string) . "'";
+                               $unicode = strlen($string) != strlen(utf8_decode($string));
+                               return ($unicode ? "N" : "") . "'" . str_replace("'", "''", $string) . "'";
                        }
 
                        function select_db($database) {