on master help sign in
Enable unicode output by default. Optional flag for suppressing unicode output.
commit834d7aa41fa6ba850701da3de289435af6b5aca0 authorDavid Himmelstrup <david.himmelstrup@erudify.com> dateWed 24 Sep 2014, 16:17 (12 years ago) parent1e6d0d9
2 files changed+14
Text/Libyaml.hs+8 yaml.cabal+6
Text/Libyaml.hs+8
@@ -310,6 +310,11 @@ foreign import ccall unsafe "get_buffer_used"
310310foreign import ccall unsafe "my_emitter_set_output"
311311 c_my_emitter_set_output :: Emitter -> Buffer -> IO ()
312312
313+#ifndef __NO_UNICODE__
314+foreign import ccall unsafe "yaml_emitter_set_unicode"
315+ c_yaml_emitter_set_unicode :: Emitter -> CInt -> IO ()
316+#endif
317+
313318foreign import ccall unsafe "yaml_emitter_set_output_file"
314319 c_yaml_emitter_set_output_file :: Emitter -> File -> IO ()
315320
@@ -618,6 +623,9 @@ runEmitter allocI closeI =
618623 emitter <- mallocBytes emitterSize
619624 res <- c_yaml_emitter_initialize emitter
620625 when (res == 0) $ throwIO $ YamlException "c_yaml_emitter_initialize failed"
626+#ifndef __NO_UNICODE__
627+ c_yaml_emitter_set_unicode emitter 1
628+#endif
621629 a <- allocI emitter
622630 return (emitter, a)
623631 cleanup (emitter, _) = do
yaml.cabal+6
@@ -37,6 +37,10 @@ flag system-libyaml
3737 description: Use the system-wide libyaml instead of the bundled copy
3838 default: False
3939
40+flag no-unicode
41+ description: Don't enable unicode output. Instead, unicode characters will be escaped.
42+ default: False
43+
4044library
4145 build-depends: base >= 4 && < 5
4246 , transformers >= 0.1
@@ -58,6 +62,8 @@ library
5862 ghc-options: -Wall
5963 c-sources: c/helper.c
6064 include-dirs: c
65+ if flag(no-unicode)
66+ cpp-options: -D__NO_UNICODE__
6167 if flag(system-libyaml)
6268 pkgconfig-depends: yaml-0.1
6369 else