Can I specify an explicit encoding while doing commit?

Asked by Chen Zhuhui

Well, I use bzr under Windows XP. Default encoding of my os is `gbk' while I want to write my commit message in utf-8 encoding. But each time when I try to do so, bzr will throw out an error:

------------------------------------------------------------------------
E:\bzrbzr>bzr commit --unchanged --file log.txt
Committing to: E:/bzrbzr/
aborting commit write group: UnicodeDecodeError('gbk', '\xe8\xbf\x99\xe6\x98\xaf
\xe6\xb6\x88\xe6\x81\xaf\xe8\xae\xb0\xe5\xbd\x95\xe6\x96\x87\xe4\xbb\xb6\xe3\x80
\x82\n', 26, 28, 'illegal multibyte sequence')
bzr: ERROR: exceptions.UnicodeDecodeError: 'gbk' codec can't decode bytes in pos
ition 26-27: illegal multibyte sequence

Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 826, in exception_to_return_code
  File "bzrlib\commands.pyo", line 1027, in run_bzr
  File "bzrlib\commands.pyo", line 638, in run_argv_aliases
  File "bzrlib\builtins.pyo", line 3131, in run
  File "bzrlib\decorators.pyo", line 194, in write_locked
  File "bzrlib\workingtree_4.pyo", line 197, in commit
  File "bzrlib\decorators.pyo", line 194, in write_locked
  File "bzrlib\mutabletree.pyo", line 225, in commit
  File "bzrlib\commit.pyo", line 257, in commit
  File "bzrlib\cleanup.pyo", line 117, in run
  File "bzrlib\cleanup.pyo", line 147, in _do_with_cleanups
  File "bzrlib\commit.pyo", line 398, in _commit
  File "bzrlib\builtins.pyo", line 3115, in get_message
  File "codecs.pyo", line 618, in read
UnicodeDecodeError: 'gbk' codec can't decode bytes in position 26-27: illegal mu
ltibyte sequence

bzr 2.1.0b4 on python 2.5.4 (Windows-XP-5.1.2600-SP3)
arguments: ['bzr', 'commit', '--unchanged', '--file', 'log.txt']
encoding: 'cp936', fsenc: 'mbcs', lang: None
plugins:
  bzrtools C:\Program Files\Bazaar\plugins\bzrtools [2.1.0b1]
  explorer C:\Program Files\Bazaar\plugins\explorer [0.10.0]
  launchpad C:\Program Files\Bazaar\plugins\launchpad [2.1.0b4]
  netrc_credential_store C:\Program Files\Bazaar\plugins\netrc_credential_store
[2.1.0b4]
  qbzr C:\Program Files\Bazaar\plugins\qbzr [0.17.0]
  rebase C:\Program Files\Bazaar\plugins\rebase [0.5.5]
  svn C:\Program Files\Bazaar\plugins\svn [1.0.1]
  upload C:\Program Files\Bazaar\plugins\upload [1.0.0dev]
  xmloutput C:\Program Files\Bazaar\plugins\xmloutput [0.8.5]

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description of the problem.
-------------------------------------------------------------------------------------------------------------

`log.txt' is utf-8 encoded and contains some whatever Chinese characters.

So... can I specify an explicit encoding of the message while doing commit? Or any other ways to do it successfully without changing the encoding of `log.txt' to system's default encoding(gbk)?

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Chen Zhuhui
Solved:
Last query:
Last reply:
Revision history for this message
Martin Pool (mbp) said :
#1

Hi,

At the moment the commit message must be in the system encoding. Bug 520604 asks for an option to use a different one.

Revision history for this message
Chen Zhuhui (ekschencn) said :
#2

Thanks Martin.

Sincerely hope this option can be implemented soon. :-)