diff options
| author | Yasuhiro Matsumoto <[email protected]> | 2015-09-11 11:12:03 +0900 |
|---|---|---|
| committer | Yasuhiro Matsumoto <[email protected]> | 2015-09-11 11:12:03 +0900 |
| commit | 8277e950eee4e8c6135eca281a7d5ca91077d2b4 (patch) | |
| tree | b8c78e65be2d634694eed3ae12f72b6076631fe1 /mrbgems/mruby-print | |
| parent | 3ed8e7fbb24886619f6e7aa2e9be1d0dd0609feb (diff) | |
| download | mruby-8277e950eee4e8c6135eca281a7d5ca91077d2b4.tar.gz mruby-8277e950eee4e8c6135eca281a7d5ca91077d2b4.zip | |
Support windows locale
Add mrb_utf8_from_locale, mrb_utf8_free, mrb_locale_from_utf8, mrb_locale_free. Just works for windows.
Diffstat (limited to 'mrbgems/mruby-print')
| -rw-r--r-- | mrbgems/mruby-print/src/print.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mrbgems/mruby-print/src/print.c b/mrbgems/mruby-print/src/print.c index 673ba2172..e7e21dd4b 100644 --- a/mrbgems/mruby-print/src/print.c +++ b/mrbgems/mruby-print/src/print.c @@ -1,17 +1,18 @@ #include "mruby.h" #include "mruby/string.h" #include <stdio.h> +#include <string.h> +#include <stdlib.h> static void printstr(mrb_state *mrb, mrb_value obj) { - char *s; - mrb_int len; - if (mrb_string_p(obj)) { - s = RSTRING_PTR(obj); - len = RSTRING_LEN(obj); - fwrite(s, len, 1, stdout); + char* ptr = mrb_locale_from_utf8(RSTRING_PTR(obj), RSTRING_LEN(obj)); + if (ptr) { + fwrite(ptr, strlen(ptr), 1, stdout); + mrb_locale_free(ptr); + } } } |
