on master help sign in
Enable unicode output by default. Optional flag for suppressing unicode output.
834d7aaDavid Himmelstrup
Text/Libyaml.hs+8
@@ -310,6 +310,11 @@ foreign import ccall unsafe "get_buffer_used"
310foreign import ccall unsafe "my_emitter_set_output"
310foreign import ccall unsafe "my_emitter_set_output"
311 c_my_emitter_set_output :: Emitter -> Buffer -> IO ()
311 c_my_emitter_set_output :: Emitter -> Buffer -> IO ()
312
312
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+
313foreign import ccall unsafe "yaml_emitter_set_output_file"
318foreign import ccall unsafe "yaml_emitter_set_output_file"
314 c_yaml_emitter_set_output_file :: Emitter -> File -> IO ()
319 c_yaml_emitter_set_output_file :: Emitter -> File -> IO ()
315
320
@@ -618,6 +623,9 @@ runEmitter allocI closeI =
618 emitter <- mallocBytes emitterSize
623 emitter <- mallocBytes emitterSize
619 res <- c_yaml_emitter_initialize emitter
624 res <- c_yaml_emitter_initialize emitter
620 when (res == 0) $ throwIO $ YamlException "c_yaml_emitter_initialize failed"
625 when (res == 0) $ throwIO $ YamlException "c_yaml_emitter_initialize failed"
626+#ifndef __NO_UNICODE__
627+ c_yaml_emitter_set_unicode emitter 1
628+#endif
621 a <- allocI emitter
629 a <- allocI emitter
622 return (emitter, a)
630 return (emitter, a)
623 cleanup (emitter, _) = do
631 cleanup (emitter, _) = do
yaml.cabal+6
@@ -37,6 +37,10 @@ flag system-libyaml
37 description: Use the system-wide libyaml instead of the bundled copy
37 description: Use the system-wide libyaml instead of the bundled copy
38 default: False
38 default: False
39
39
40+flag no-unicode
41+ description: Don't enable unicode output. Instead, unicode characters will be escaped.
42+ default: False
43+
40library
44library
41 build-depends: base >= 4 && < 5
45 build-depends: base >= 4 && < 5
42 , transformers >= 0.1
46 , transformers >= 0.1
@@ -58,6 +62,8 @@ library
58 ghc-options: -Wall
62 ghc-options: -Wall
59 c-sources: c/helper.c
63 c-sources: c/helper.c
60 include-dirs: c
64 include-dirs: c
65+ if flag(no-unicode)
66+ cpp-options: -D__NO_UNICODE__
61 if flag(system-libyaml)
67 if flag(system-libyaml)
62 pkgconfig-depends: yaml-0.1
68 pkgconfig-depends: yaml-0.1
63 else
69 else