diff options
| author | Yasuhiro Matsumoto <[email protected]> | 2017-12-13 22:28:18 +0900 |
|---|---|---|
| committer | Yasuhiro Matsumoto <[email protected]> | 2017-12-13 22:28:18 +0900 |
| commit | 0ab9ac6b2207466c01fc79bfeb37534d41c55b6c (patch) | |
| tree | b5c7e3d1e9f8a71ce430c89d482a93e9c94d7a25 | |
| parent | 55fced30cd4e333916f5a02500c05dbae28fd86e (diff) | |
| download | mruby-0ab9ac6b2207466c01fc79bfeb37534d41c55b6c.tar.gz mruby-0ab9ac6b2207466c01fc79bfeb37534d41c55b6c.zip | |
fix locale in mirb
| -rw-r--r-- | mrbgems/mruby-bin-mirb/tools/mirb/mirb.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c index 2447601aa..a58a72e7d 100644 --- a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +++ b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c @@ -95,6 +95,7 @@ static void p(mrb_state *mrb, mrb_value obj, int prompt) { mrb_value val; + char* msg; val = mrb_funcall(mrb, obj, "inspect", 0); if (prompt) { @@ -108,7 +109,9 @@ p(mrb_state *mrb, mrb_value obj, int prompt) if (!mrb_string_p(val)) { val = mrb_obj_as_string(mrb, obj); } - fwrite(RSTRING_PTR(val), RSTRING_LEN(val), 1, stdout); + msg = mrb_locale_from_utf8(RSTRING_PTR(val), RSTRING_LEN(val)); + fwrite(msg, strlen(msg), 1, stdout); + mrb_locale_free(msg); putc('\n', stdout); } @@ -537,11 +540,15 @@ done: else { if (0 < parser->nwarn) { /* warning */ - printf("line %d: %s\n", parser->warn_buffer[0].lineno, parser->warn_buffer[0].message); + char* msg = mrb_locale_from_utf8(parser->warn_buffer[0].message, -1); + printf("line %d: %s\n", parser->warn_buffer[0].lineno, msg); + mrb_utf8_free(msg); } if (0 < parser->nerr) { /* syntax error */ - printf("line %d: %s\n", parser->error_buffer[0].lineno, parser->error_buffer[0].message); + char* msg = mrb_locale_from_utf8(parser->error_buffer[0].message, -1); + printf("line %d: %s\n", parser->error_buffer[0].lineno, msg); + mrb_utf8_free(msg); } else { /* generate bytecode */ |
