| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Collection of functions and classes to fix various encoding problems on | 5 """Collection of functions and classes to fix various encoding problems on |
| 6 multiple platforms with python. | 6 multiple platforms with python. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import codecs | 9 import codecs |
| 10 import locale | 10 import locale |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 # "It doesn't appear to be possible to read Unicode characters in UTF-8 | 349 # "It doesn't appear to be possible to read Unicode characters in UTF-8 |
| 350 # mode" and this appears to be a limitation of cmd.exe. | 350 # mode" and this appears to be a limitation of cmd.exe. |
| 351 except Exception as e: | 351 except Exception as e: |
| 352 complain('exception %r while fixing up sys.stdout and sys.stderr' % e) | 352 complain('exception %r while fixing up sys.stdout and sys.stderr' % e) |
| 353 return True | 353 return True |
| 354 | 354 |
| 355 | 355 |
| 356 def fix_encoding(): | 356 def fix_encoding(): |
| 357 """Fixes various encoding problems on all platforms. | 357 """Fixes various encoding problems on all platforms. |
| 358 | 358 |
| 359 Should be called at the very begining of the process. | 359 Should be called at the very beginning of the process. |
| 360 """ | 360 """ |
| 361 ret = True | 361 ret = True |
| 362 if sys.platform == 'win32': | 362 if sys.platform == 'win32': |
| 363 ret &= fix_win_codec() | 363 ret &= fix_win_codec() |
| 364 | 364 |
| 365 ret &= fix_default_encoding() | 365 ret &= fix_default_encoding() |
| 366 | 366 |
| 367 if sys.platform == 'win32': | 367 if sys.platform == 'win32': |
| 368 encoding = sys.getdefaultencoding() | 368 encoding = sys.getdefaultencoding() |
| 369 ret &= fix_win_sys_argv(encoding) | 369 ret &= fix_win_sys_argv(encoding) |
| 370 ret &= fix_win_console(encoding) | 370 ret &= fix_win_console(encoding) |
| 371 return ret | 371 return ret |
| OLD | NEW |