qq15725 / modern-screenshot

📸 Quickly generate image from DOM node using HTML5 canvas and SVG
https://www.toolpkg.com/image/html-to-image
MIT License
457 stars 32 forks source link

Error when rendering emoji on Safari #69

Open DontGiveAFck opened 7 months ago

DontGiveAFck commented 7 months ago

Steps To Reproduce

  1. open https://modern-screenshot.vercel.app/ on Safari 17.1 macos
  2. add emoji symbol to the page (😀)
  3. notice that there is an error in console
image
Unhandled Promise Rejection: URIError: String contained an illegal UTF-16 sequence.

```txt ```

Your Environment

jbergfi commented 6 months ago

I had same problem here. After a bit of browsing of the code I found the removeControlCharacter flag and setting that to false seems to fix the issue. Note sure what the flag is supposed to do but it seems it removes too much.

So adding this to options should do the trick:

let options = {
  features: {
    removeControlCharacter: false
  }
}
debugtheworldbot commented 2 months ago

I had same problem here. After a bit of browsing of the code I found the removeControlCharacter flag and setting that to false seems to fix the issue. Note sure what the flag is supposed to do but it seems it removes too much.

So adding this to options should do the trick:

let options = {
  features: {
    removeControlCharacter: false
  }
}

Thanks. you saved my day