m4ns0ur / base64-vscode-plugin

Plugin to encode/decode base64 data
MIT License
2 stars 0 forks source link

Incorrect result with non-ASCII characters #1

Closed capcom6 closed 1 year ago

capcom6 commented 1 year ago

Hello,

I noticed there is a problem with encoding non-ASCII text in UTF-8 encoding. For example, when we try to encode the text Тест, we receive the string IjVBQg==. However, when we attempt to decode this string, we receive the result "5AB, instead of the original string.

On the other hand, if we use the console base64 utility, such as echo -n Тест | base64 -w 0, we get 0KLQtdGB0YI=. In JavaScript, I obtain the same result if I use the utf8 encoding in the Buffer.from function: Buffer.from('Тест', 'utf8').toString('base64').

Thank you.

m4ns0ur commented 1 year ago

Nice catch! Thanks