Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js: support UTF-8 mujs API with a header-only wrapper
The mujs C API expects input strings to be encoded as CESU-8, and similarly strings from the VM are CESU-8 encoded. CESU-8 differs from UTF-8 encoding only for codepoints >= U+10000 . Till now mpv ignored this requirement and as a result emoji and other non-BMP codepoints were not processed correctly (nothing blew though). Now such codepoints work and converted correctly in all mujs APIs to/from CESU-8, including in script source files. This commit uses a single-header wrapper which replaces all the mujs CESU-8 string APIs with UTF-8 ones with identical names. In mpv it's almost entirely fully transparent because mpv currently doesn't use custom allocator or callbacks (which are not wrapped automatically). mpv does use js_Report, but for now we'll live with the rare cases where reports require conversion to UTF-8 (possibly reported function names with emoji etc), though it's trivial to make it UTF-8 as well. The wrapper header - mujsutf8.h - is stand alone and does not depend on any mpv code or headers.
- Loading branch information