unicode box drawing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jefm

    unicode box drawing

    How can I print the unicode box drawing characters in python:


    print u'\u2500'
    print u'\u2501'
    print u'\u2502'
    print u'\u2503'
    print u'\u2504'

    Traceback (most recent call last):
    File "\test.py", line 3, in ?
    print u'\u2500'
    File "C:\Python24\li b\encodings\cp1 252.py", line 18, in encode
    return codecs.charmap_ encode(input,er rors,encoding_m ap)
    UnicodeEncodeEr ror: 'charmap' codec can't encode character u'\u2500'
    in position 0: character maps to <undefined>
  • Nanjundi

    #2
    Re: unicode box drawing

    On Mar 4, 12:51 pm, jefm <jef.mangelsch. ..@gmail.comwro te:
    How can I print the unicode box drawing characters in python:
    >
    print u'\u2500'
    print u'\u2501'
    print u'\u2502'
    print u'\u2503'
    print u'\u2504'
    >
    Traceback (most recent call last):
    File "\test.py", line 3, in ?
    print u'\u2500'
    File "C:\Python24\li b\encodings\cp1 252.py", line 18, in encode
    return codecs.charmap_ encode(input,er rors,encoding_m ap)
    UnicodeEncodeEr ror: 'charmap' codec can't encode character u'\u2500'
    in position 0: character maps to <undefined>
    Just FYI, not an answer.

    It works like a charm on linux (ubuntu, fc3, python 2.4.1 & 2.5.2)

    Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
    [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.
    >>print u'\u2500'
    ©¤
    >>print u'\u2501'
    ©¥
    >>print u'\u2502'
    ©¦
    >>print u'\u2503'
    ©§
    >>>
    >>print u'\u2504'
    ©¨

    on windows using python 2.4. ???
    -N

    Comment

    • Marc Christiansen

      #3
      Re: unicode box drawing

      jefm <jef.mangelscho ts@gmail.comwro te:
      How can I print the unicode box drawing characters in python:
      >
      >
      print u'\u2500'
      print u'\u2501'
      print u'\u2502'
      print u'\u2503'
      print u'\u2504'
      >
      Traceback (most recent call last):
      File "\test.py", line 3, in ?
      print u'\u2500'
      File "C:\Python24\li b\encodings\cp1 252.py", line 18, in encode
      return codecs.charmap_ encode(input,er rors,encoding_m ap)
      UnicodeEncodeEr ror: 'charmap' codec can't encode character u'\u2500'
      in position 0: character maps to <undefined>
      On linux in an utf8 console, it works with 2ython 2.4.4 and 2.5.1. It
      looks like your python is using cp 1252 for output. Which does not
      contain the box drawing characters. I don't think using a different
      encoding would work (e.g. print u'\u2500'.encod e('cp437'), or print
      u'\u2500'.encod e('utf8'))

      Marc

      Comment

      • jefm

        #4
        Re: unicode box drawing

        on windows using python 2.4. ???

        yes, as a matter of fact I am.
        Did not feel the need to switch to 2.5 yet.
        I'm gonna give this a try, but it requires me to dig up 2.5 versions
        of the libraries i am using.
        (one of them didn't at the time and that is why I stuck to 2.4)

        Comment

        • jefm

          #5
          Re: unicode box drawing

          on windows using python 2.4. ???


          I was on Python 2.4.3 and it gave me that problem.
          I upgraded to 2.4.4 and it works.
          thanks for the tip.

          Comment

          Working...