Skip to content

an error "UnhandledPromiseRejectionWarning: Error: EILSEQ, Illegal byte sequence" occurred when using Japanese characters on loadImage function #1802

Open
@kanchi0914

Description

@kanchi0914

Issue or Feature

As the title suggests.

Steps to Reproduce

const { loadImage } = require('canvas')
const myimg = loadImage('あ.jpg')

The results are as follows:

(node:23792) UnhandledPromiseRejectionWarning: Error: EILSEQ, Illegal byte sequence 'あ.jpg'
    at setSource (C:\Users\user\WebstormProjects\myProject\node_modules\canvas\lib\image.js:91:13)
    at Image.set (C:\Users\user\WebstormProjects\myProject\node_modules\canvas\lib\image.js:62:9)
    at C:\Users\user\WebstormProjects\myProject\node_modules\canvas\index.js:34:15
    at new Promise (<anonymous>)
    at loadImage (C:\Users\user\WebstormProjects\myProject\node_modules\canvas\index.js:23:10)
    at Object.<anonymous> (C:\Users\user\WebstormProjects\myProject\main.js:2:15)
    at Module._compile (internal/modules/cjs/loader.js:1236:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
    at Module.load (internal/modules/cjs/loader.js:1085:32)
    at Function.Module._load (internal/modules/cjs/loader.js:950:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:23792) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:23792) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

So is it not supported using Japanese or other languages for a file name? I confirmed It can be reproduced when using Korean or Chinese characters too.
thanks.

Your Environment

  • Version of node-canvas : [email protected]
  • Environment : node v14.6.0, Windows 10 Pro x64 version 20H2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions