Skip to content

Commit

Permalink
Fix windows codepage detection using language pack
Browse files Browse the repository at this point in the history
When running `chcp` on a german Windows installation, the output contains a `.` after the code page:

```
> chcp
Aktive Codepage: 850.
```

Allow an optional dot in the output parsing.
  • Loading branch information
peace-maker committed Dec 15, 2024
1 parent 551dd3f commit 6792f69
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ambuild2/frontend/cpp/msvc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ def GetCodePage():
stdout = subprocess.PIPE,
stderr = subprocess.DEVNULL,
stdin = subprocess.DEVNULL).stdout
codec = 'cp' + re.match(b".+: (\d+)\s*$", stdout).group(1).decode()
code_page = re.match(br".+: (\d+)\.?\s*$", stdout)
if code_page is None:
raise LookupError("Could not determine code page")
codec = 'cp' + code_page.group(1).decode()
codecs.lookup(codec)
return codec
except LookupError:
Expand Down

0 comments on commit 6792f69

Please sign in to comment.