Then no, we are not. I set my host name to:
samus憟
And python socket.gethostname() returned:
'samus\xb5\xe5\x83'
Which can be ".decode('cp1252')" to give the right string. If I try .decode('iso-8859-1') it doesn't convert the ƒ character correctly (it exists in the cp1252 codepage, but *not* in iso-8859-1.
Now, Alexander has actually done the work in win32utils.py to write the function "get_host_name()" which is able to use a Unicode-aware api in windows (!win98) GetComputerNameW. Which returns a proper unicode string:
>>> bzrlib.win32utils.get_host_name()
u'SAMUS\xb5\xc5\u0192'
Note, however, that 'socket.gethostname()' returns the lowercase form at GetComputerNameW() returns the upper-case form. I'm guessing GetComputerNameW is returning the NETBIOS name, which is always in upper case.
Now, I'm guessing on the COMPUTER_NAME_FORMAT parameter, because it is an enum, and they don't actually mention the mapping. But I'm thinking we might actually want '3' =ComputerNameDnsFullyQualified http://msdn.microsoft.com/en-us/library/ms724224(VS.85).aspx
So it might just make sense to write an 'osutils.gethostname()' which returns a unicode string, and calls over into GetComputeNameExW on windows when available.
Provided Robert is talking about "punycode": https:/ /designarchitec ture.com: 19638/docs/ en_US/user/ oh_user_ overview_ of_internationa lized_domain_ names_idn. htm#Translation _of_IDNs
Then no, we are not. I set my host name to:
samus憟
And python socket. gethostname( ) returned:
'samus\xb5\xe5\x83'
Which can be ".decode('cp1252')" to give the right string. If I try .decode( 'iso-8859- 1') it doesn't convert the ƒ character correctly (it exists in the cp1252 codepage, but *not* in iso-8859-1.
Now, Alexander has actually done the work in win32utils.py to write the function "get_host_name()" which is able to use a Unicode-aware api in windows (!win98) GetComputerNameW. Which returns a proper unicode string: win32utils. get_host_ name() xb5\xc5\ u0192'
>>> bzrlib.
u'SAMUS\
Note, however, that 'socket. gethostname( )' returns the lowercase form at GetComputerNameW() returns the upper-case form. I'm guessing GetComputerNameW is returning the NETBIOS name, which is always in upper case.
Now, according to MSDN, there is another function: msdn.microsoft. com/en- us/library/ ms724301( VS.85). aspx
http://
GetComputerNameEx (I assume this will become GetComputerNameExW when appropriate).
If I manually hack together something with cytpes, and I do:
>>> ctypes. windll. kernel32. GetComputerName ExW(3, buf, n) xb5\xe5\ u0192'
>>> buf.value
u'samus\
Now, I'm guessing on the COMPUTER_ NAME_FORMAT parameter, because it is an enum, and they don't actually mention the mapping. But I'm thinking we might actually want '3' =ComputerNameDn sFullyQualified msdn.microsoft. com/en- us/library/ ms724224( VS.85). aspx
http://
So it might just make sense to write an 'osutils. gethostname( )' which returns a unicode string, and calls over into GetComputeNameExW on windows when available.