trevorc / timebook

MIT License
0 stars 0 forks source link

Problem with mismatched encodings for terminal and command line arguments on Windows #11

Closed trevorc closed 15 years ago

trevorc commented 15 years ago

Original report by Alex Yakovlev (Bitbucket: libraM, GitHub: libraM).


When on Windows it seems like text encodings for terminal (cmd.exe) and command line arguments may be different. As for my RU Windows Vista, it's cp866 and cp1251 respectively.

It makes t almost unusable for real work with non-ASCII strings (timesheet names and notes) now.

#!cmd

C:\src>t switch Работа

C:\src>t current
╨рсюЄр

<<changeset 114b8f29fc75>> made it possible to set user encoding from command line:

#!cmd

C:\src>t -e cp1251 switch Работа

C:\src>t current
Работа

But I hope there is a better way to solve the problem.

Current version of bzr - http://bazaar-vcs.org - works great in this regard. So I extracted bzr's code responsible for encoding guessing (from http://bazaar.launchpad.net/~bzr/bzr/trunk/annotate/head%3A/bzrlib//osutils.py).

It would be nice to integrate get_user_encoding() from bzr into timebook as a more sane default user encoding instead of sys.stdin.encoding.

trevorc commented 15 years ago

Original comment by Trevor Caira (Bitbucket: trevor, GitHub: trevor).


I can't incorporate that module since it is GPL-licensed. However I will take a stab at this issue.

trevorc commented 15 years ago

Original comment by Trevor Caira (Bitbucket: trevor, GitHub: trevor).


Let me know if <<cset 4b6bf9284996>> fixes this for you.

trevorc commented 15 years ago

Original comment by Alex Yakovlev (Bitbucket: libraM, GitHub: libraM).


Now t works smoothly as expected. Thank you.