1

I'm creating pdf documentation of engineering calculations using reportlab. I stick to the notation used in the code being implemented. This uses mainly Latin and Greek letters, sub- and superscripts. For these I implemented a very simple method that is based on replacing certain strings in the text to unicode characters, before generating the pdf. It could be done otherwise but it works. One problem, however eludes me: creating characters using combining characters, in particular characters with bars over them, say the Latin "d" with a bar.

>>> print('b'+u'\u0304')

produces in the python console the bar next to "b" (note in the editor of stackoverflow the result is as expected :-)). However, the same with an accent works in the console:

>>> print('fue'+ u'\u0301')

Any ideas where my mistake is?

jake77
  • 1,892
  • 2
  • 15
  • 22
  • My console displays b with a bar over it. I am using a utf8 console on linux (peeking at `sys.stdout.encoding`). Are you on windows? This may be a code page thing. – tdelaney Oct 15 '16 at 19:16
  • Yes, it is Win8. To make things more interesting: print('e'+u'\u0304') works as expected. – jake77 Oct 15 '16 at 19:29
  • 1
    I think its a question of whether your code page has the code point. You can load a module that will make python use the wide-string version of the console api and that can help. I think this addresses the issue https://www.python.org/dev/peps/pep-0528/ but don't have windows handy to check it out. – tdelaney Oct 15 '16 at 19:34
  • Seems plausible to me - thanks for the effort! I think I'll just give up sticking to the code notation and find a suitable replacement for that bar. The issue will be solved in a few years time anyways :-) – jake77 Oct 15 '16 at 19:43
  • Why are you using a `+` to combine those strings? You can write just: `'fue\u0301'` o `'b\u0304'`... – Bakuriu Oct 15 '16 at 19:46
  • True that but unfortunately the output is unchanged. – jake77 Oct 15 '16 at 20:20

0 Answers0