Repository navigation
Use locale.getpreferredencoding rather than locale.getlocale as latter can fail if Python doesn't know the locale #11384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,8 @@ | ||||||||||
| # -*- coding: UTF-8 -*- | ||||||||||
|
lukaszgo1 marked this conversation as resolved.
Outdated
|
||||||||||
| #textUtils.py | ||||||||||
| #A part of NonVisual Desktop Access (NVDA) | ||||||||||
| #This file is covered by the GNU General Public License. | ||||||||||
| #See the file COPYING for more details. | ||||||||||
| #Copyright (C) 2018-2019 NV Access Limited, Babbage B.V. | ||||||||||
| # A part of NonVisual Desktop Access (NVDA) | ||||||||||
| # This file is covered by the GNU General Public License. | ||||||||||
| # See the file COPYING for more details. | ||||||||||
| # Copyright (C) 2018-2020 NV Access Limited, Babbage B.V., Łukasz Golonka | ||||||||||
|
|
||||||||||
| """ | ||||||||||
| Classes and utilities to deal with offsets variable width encodings, particularly utf_16. | ||||||||||
|
|
@@ -18,6 +17,8 @@ | |||||||||
| from logHandler import log | ||||||||||
|
|
||||||||||
| WCHAR_ENCODING = "utf_16_le" | ||||||||||
| USERANSICODEPAGE = locale.getpreferredencoding() | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the style used for constants here:
Suggested change
Or rather
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've renamed it to |
||||||||||
|
|
||||||||||
|
|
||||||||||
| class WideStringOffsetConverter: | ||||||||||
| R""" | ||||||||||
|
|
@@ -201,7 +202,7 @@ def getTextFromRawBytes( | |||||||||
| if numChars > 1 and any(buf[numChars:]): | ||||||||||
| encoding = WCHAR_ENCODING | ||||||||||
| else: | ||||||||||
| encoding = locale.getlocale()[1] | ||||||||||
| encoding = USERANSICODEPAGE | ||||||||||
| else: | ||||||||||
| encoding = encodings.normalize_encoding(encoding).lower() | ||||||||||
| if encoding.startswith("utf_16"): | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.