Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- respect text encoding specified in argument (thanks to @ryohji for the contribution) #20796

### Other Changes

## 1.19.0 (2021-09-30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ def text(self, encoding: Optional[str] = None) -> str:
ctype = self.headers.get(aiohttp.hdrs.CONTENT_TYPE, "").lower()
mimetype = aiohttp.helpers.parse_mimetype(ctype)

encoding = mimetype.parameters.get("charset")
if not encoding:
# extract encoding from mimetype, if caller does not specify
encoding = mimetype.parameters.get("charset")
if encoding:
try:
codecs.lookup(encoding)
Expand All @@ -372,7 +374,7 @@ def text(self, encoding: Optional[str] = None) -> str:
)
else:
encoding = chardet.detect(body)["encoding"]
if not encoding:
if encoding == "utf-8" or encoding is None:
encoding = "utf-8-sig"

return body.decode(encoding)
Expand Down