unicodeocamlreasonbucklescript

Bucklescript is compiling utf8 ReasonML files into us-ascii


I'm using ReasonReact with bsb -init myapp -theme react-hooks. I run my project on MacOS Catalina. When building or starting my project, Bucklescript is compiling my utf8 *.re files into us-ascii. This results into bad encoded accentuated characters. I cannot figure out why. Thanks for helping me out.


Solution

  • It's not clear from the question whether you use unicode characters only in string literals, or in identifiers.

    If the former, BuckleScript provides syntax for unicode string literals, which should be translated correctly:

    let unicode = {js|你好, 世界|js};
    

    If you use unicode in identifiers, however, the compiler unfortunately does not support that. It's an internal limitation inherited from the OCaml compiler.