Skip to content

Unicode strings inside the first argument to Printf.sprintf get garbled #1000

@feihong

Description

@feihong

Here's a simple example:

let message = Printf.sprintf({js|Greetings and 你好, %s!|js}, "Jon");
Js.log(message);

This produces

Greetings and ä½ å¥½, Jon!

Playground link


Interestingly, native OCaml doesn't have this problem:

% ocaml
OCaml version 5.0.0
Enter #help;; for help.

# Printf.printf {js|Greetings and 你好, %s!|js} "Jon";;
Greetings and 你好, Jon!- : unit = ()
#

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions