summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-print
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-09-11 11:42:03 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-09-11 11:42:03 +0900
commiteb9bec19dcb99bf0a6934471fb8f35e80beb8719 (patch)
treeb8c78e65be2d634694eed3ae12f72b6076631fe1 /mrbgems/mruby-print
parent3ed8e7fbb24886619f6e7aa2e9be1d0dd0609feb (diff)
parent8277e950eee4e8c6135eca281a7d5ca91077d2b4 (diff)
downloadmruby-eb9bec19dcb99bf0a6934471fb8f35e80beb8719.tar.gz
mruby-eb9bec19dcb99bf0a6934471fb8f35e80beb8719.zip
Merge pull request #1822 from mattn/locale
Add mrb_utf8_from_locale, mrb_utf8_free, mrb_locale_from_utf8, mrb_locale_free
Diffstat (limited to 'mrbgems/mruby-print')
-rw-r--r--mrbgems/mruby-print/src/print.c13
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);
+ }
}
}