0

I use SAS to access files. So i can get the files’ content by send a request.

But the problem is that i need to change the file’s encoding to SJIS.

so i’m trying to use Encoding.convert(), according to this (https://github.com/polygonplanet/encoding.js/blob/master/README_ja.md)

After this I’m going to use

URL.createObjectURL(new Blob([sjiscontent], {type: "text.plain"}))

But I don’t know how to convert my blobs’ string context to a sjis utf8arrary properly.

Jaydeep
  • 1,628
  • 1
  • 16
  • 28
Jeff_hu
  • 415
  • 2
  • 15

1 Answers1

0

Try to use the Streaming APIs of iconv-lite and request node packages to convert the content encoding in a stream.

For example, you have a blob url with SAS token.

var request = require('request');
var iconv = require('iconv-lite');
request('<a blob url with sas token>')
    .pipe(iconv.decodeStream('UTF-8'))
    .pipe(iconv.encodeStream('shift_jis'))
    .pipe(fs.createWriteStream('<your local file path>'))

The iconv-lite package supports Shift_JIS (SJIS) encoding.

Peter Pan
  • 22,121
  • 4
  • 21
  • 39