Automattic / Automattic/node-canvas

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

Open
#1,802 2 comments 0 reactions 0 assignees View on GitHub
Bug Help wanted
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## Issue or Feature

As the title suggests.

## Steps to Reproduce

```js
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 ()
at loadImage (C:\Users\user\WebstormProjects\myProject\node_modules\canvas\index.js:23:10)
at Object. (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 : canvas@2.7.0
* Environment : node v14.6.0, Windows 10 Pro x64 version 20H2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.