Jump to content

Hi I 'm working on a project to try to understand most of the twit coding 101 is teaching but th...


 Share

Recommended Posts

Hi I'm working on a project to try to understand most of the twit coding 101 is teaching but there is one issue that I'm pretty sure they will not cover and was hoping that some one here could help me with, I'm having players of a CLI based game enter their name but we here in Iceland have all those weird letters that python is not happy with, like Þ ó é í ö æ ð, I'm pretty sure that this is because Python is not using utf8 by default but I cant find a way to deal with this on the google.  can some one help or point me in the right direction ?

   

Link to comment
Share on other sites

Python 2.7 has a different data type for Unicode strings. I'd recommend you start with Python 3, which has better Unicode integration (all strings are Unicode by default, and source is assumed to be utf8). The only thing you'll need to change from Padre's examples is to make sure you call print() as a function. BTW, you can install both versions of Python on one computer and they will politely stay out of each others way.

Link to comment
Share on other sites

Strange, I have no trouble on Debian. This is a simple transcript of a command line session in another window:

 

    lee@aces:~$ python3

    Python 3.3.5 (default, Mar 22 2014, 13:24:53)[GCC 4.8.2] on linux

    Type "help", "copyright", "credits" or "license" for more information.

    >>> s = input("String:")

    String:aböcédþfðg

    >>> print(s)

    aböcédþfðg

    >>> 

 

Of course I had to copy the thorn and edh in from charmap since there's no compose-key sequence for them, but I assume you have an Icelandic keyboard so that's not an issue. Perhaps your system just isn't configured correctly for your keyboard?

Link to comment
Share on other sites

Just got the alt codes for the troublesome characters. Will try typing instead of copying. 

 

alt 0254 => þ

alt 0240 => ð

 

EDIT: The alt codes work for windows. shift ctrl u + unicode should work on ubuntu. 

 

00DE 00FE works for lower+ uppercase thorn

U+00D0 U+00F0 isn't putting the character on screen. 

 

Anyway both thorn's print fine for me. Will have to play with it more.

Link to comment
Share on other sites

 Share

×
×
  • Create New...