about summary refs log tree commit diff
path: root/Test/D07multibyte.ztst
diff options
context:
space:
mode:
Diffstat (limited to 'Test/D07multibyte.ztst')
-rw-r--r--Test/D07multibyte.ztst56
1 files changed, 42 insertions, 14 deletions
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 7f046525a..413c4fe73 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -1,19 +1,7 @@
 %prep
 
-# Find a UTF-8 locale.
-  setopt multibyte
-# Don't let LC_* override our choice of locale.
-  unset -m LC_\*
-  mb_ok=
-  langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8
-	 $(locale -a 2>/dev/null | egrep 'utf8|UTF-8'))
-  for LANG in $langs; do
-    if [[ é = ? ]]; then
-      mb_ok=1
-      break;
-    fi
-  done
-  if [[ -z $mb_ok ]]; then
+  LANG=$(ZTST_find_UTF8)
+  if [[ -z $LANG ]]; then
     ZTST_unimplemented="no UTF-8 locale or multibyte mode is not implemented"
   else
     print -u $ZTST_fd Testing multibyte with locale $LANG
@@ -224,6 +212,20 @@
 >first
 >second
 
+  read -ed £
+0:read with multibyte delimiter where bytes of delimiter also occur in input
+<one¤twoãthree£four
+>one¤twoãthree
+
+  read -ed $'\xa0' <<<$'first\xa0second'
+0:read delimited by a byte that isn't a valid multibyte character
+>first
+
+  read -ed $'\xc2'
+0:read delimited by a single byte terminates if the byte is part of a multibyte character
+<one£two
+>one
+
   (IFS=«
   read -d » -A array
   print -l $array)
@@ -347,6 +349,18 @@
 0:Multibyte characters in printf widths
 > főo
 
+# TODO?: POSIX requires that printf should always compute width and
+# precision of '%s' conversion in bytes, while zsh computes them in
+# characters if multi-byte locale is in use.
+  ARGV0=sh $ZTST_testdir/../Src/zsh -c "printf '<%10s>\n' St$'\M-C\M-)'phane"
+0f:POSIX: width in %s should be computed in bytes, not in characters
+F:This is considered a bugfix in zsh
+>< Stéphane>
+
+  ARGV0=sh $ZTST_testdir/../Src/zsh -c "printf '<%7.5s>\n' St$'\M-C\M-)'phane"
+0f:POSIX: precision should also be computed in bytes, not in characers
+><  Stép>
+
 # We ask for case-insensitive sorting here (and supply upper case
 # characters) so that we exercise the logic in the shell that lowers the
 # case of the string for case-insensitive sorting.
@@ -615,3 +629,17 @@ F:support character sets outside the portable 7-bit range.
 0:locale gets restored when locale parameters go out of scope (regression test for 45772)
 >❯
 >❯
+
+  # Subshell for zmodload isolation
+  (
+    zmodload zsh/stat
+    typeset -A sizes
+    touch 50150-é 50150-Ą
+    # Using +size solely in order to make it easier to write the expectations
+    zstat +size -A sizes -nor -- 50150-*
+    print -r -- 50150-Ą $sizes[50150-Ą]
+    print -r -- 50150-é $sizes[50150-é]
+  )
+0:(workers/50150) zsh/stat with Unicode and metafication
+>50150-Ą 0
+>50150-é 0