diff options
author | bptato <nincsnevem662@gmail.com> | 2023-09-27 03:07:52 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-09-27 03:07:52 +0200 |
commit | 7724082d68c452064025fa30c1c0c0127f936621 (patch) | |
tree | f922181735509d2ec066cb71e523fb6bd1757b78 /src/loader/response.nim | |
parent | 14baa050d3ab4e45879582a8f87eeb1e42407909 (diff) | |
download | chawan-7724082d68c452064025fa30c1c0c0127f936621.tar.gz |
Response.text: assume utf-8
Diffstat (limited to 'src/loader/response.nim')
-rw-r--r-- | src/loader/response.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/loader/response.nim b/src/loader/response.nim index 2be709c7..92aa5c7a 100644 --- a/src/loader/response.nim +++ b/src/loader/response.nim @@ -65,14 +65,14 @@ proc text*(response: Response): Promise[JSResult[string]] {.jsfunc.} = let bodyRead = response.bodyRead response.bodyRead = nil return bodyRead.then(proc(s: string): JSResult[string] = - if response.charset == CHARSET_UTF_8 and s.validateUtf8() == -1: + let cs = if response.charset == CHARSET_UNKNOWN: + CHARSET_UTF_8 + else: + response.charset + if cs == CHARSET_UTF_8 and s.validateUtf8() == -1: ok(s) else: let ss = newStringStream(s) - let cs = if response.charset == CHARSET_UNKNOWN: - CHARSET_UTF_8 - else: - response.charset let ds = newDecoderStream(ss, cs) let es = newEncoderStream(ds, CHARSET_UTF_8) return ok(es.readAll()) |