bodyparser icon indicating copy to clipboard operation
bodyparser copied to clipboard

auto charset decoding support

Open dead-horse opened this issue 11 years ago • 3 comments

not sure req.charset will be deprecated.

dead-horse avatar Jul 06 '14 10:07 dead-horse

close now ?

fengmk2 avatar Feb 26 '15 03:02 fengmk2

I'd like to raise the question about detection of charset encoding while parsing body data. I'm facing with problem when I interact with an external resource and this resource use callback url to return requested data. The resource requests my callback route and provide data in ISO-8895-1 (Latin-1) encoding. But all other routes should work with data in utf-8 encoding. An option to allow bodyparser detect encoding based on request header could be usefull for me.

RidgeA avatar Jan 12 '17 15:01 RidgeA

@RidgeA I had a similar issue, here is what you can do until such option exists.

  app.use(async (ctx, next) => {
    const encoding = (ctx.path.startsWith('/my/special/route')) ? 'iso-8859-1' : 'utf8';
    await bodyParser({
      encoding,
    })(ctx, next);
  });

scragg0x avatar May 18 '18 15:05 scragg0x

Closing, feel free to reopen

3imed-jaberi avatar Mar 31 '23 16:03 3imed-jaberi