apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.46k stars 3.41k forks source link

[Web] Fix string to uint8 array for special characters #17031

Closed CharlieFRuan closed 2 months ago

CharlieFRuan commented 2 months ago

This PR fixes passing Javascript string with special characters to C for web runtime.

Take the upside-down exclamation mark ¡ as an example. This should encode to \xC2\xA1 according to https://mothereff.in/utf-8#%C2%A1 and other sources:

OldStringToUint8Array("¡") --> [161, 0]
NewStringToUint8Array("¡") --> [194, 161, 0]