]> git.kaiwu.me - njs.git/commitdiff
Interactive shell: fixed non-ascii character support.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 9 Feb 2018 16:16:19 +0000 (19:16 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 9 Feb 2018 16:16:19 +0000 (19:16 +0300)
njs/njs.c
njs/test/njs_expect_test.exp

index 5c97b5240390b0a53c46b0c943bae6b1af87a4a9..ebdc5669e0ab35cfb91d4be4d6dc92d8ef0c2958 100644 (file)
--- a/njs/njs.c
+++ b/njs/njs.c
@@ -11,6 +11,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <sys/stat.h>
+#include <locale.h>
 
 #include <nxt_auto_config.h>
 #include <nxt_types.h>
@@ -459,6 +460,8 @@ njs_editline_init(njs_vm_t *vm)
     rl_attempted_completion_function = njs_completion_handler;
     rl_basic_word_break_characters = (char *) " \t\n\"\\'`@$><=;,|&{(";
 
+    setlocale(LC_ALL, "");
+
     njs_completion.completions = njs_vm_completions(vm, NULL);
     if (njs_completion.completions == NULL) {
         return NXT_ERROR;
index ea04155f2fec69d4f9659eb3e3ae0383ae7cc3b0..0f0b58c042bf34c9d94d838c0758a547be7ea6cb 100644 (file)
@@ -182,6 +182,14 @@ njs_test {
      "JSON.parse(Error()\r\nSyntaxError: Unexpected token \"\" in 1"}
 }
 
+# Non-ASCII characters
+njs_test {
+    {"'絵文字'\r\n"
+     "絵文字"}
+    {"var v = 'абвгдеёжзийкл';v[10]\r\n"
+     "й"}
+}
+
 # require('fs')
 
 set file [open njs_test_file w]