Jrnl: Can't use Brazilian Portuguese

Created on 4 Jan 2016  Â·  20Comments  Â·  Source: jrnl-org/jrnl

I've tried to write a Jrnl entry with brazilian portuguese, which has accents on some words, and I get the following error:

Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\jrnl.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\jrnl\cli.py", line 194, in run
    journal = Journal.Journal(journal_name, **config)
  File "c:\python27\lib\site-packages\jrnl\Journal.py", line 39, in __init__
    self.open()
  File "c:\python27\lib\site-packages\jrnl\Journal.py", line 108, in open
    journal = f.read()
  File "c:\python27\lib\codecs.py", line 668, in read
    return self.reader.read(size)
  File "c:\python27\lib\codecs.py", line 474, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe1 in position 127: invalid continuation byte

The word that is giving the error is "Pará"

bug windows

All 20 comments

How did you create the entry? As a one-line command, or did you just time jrnl and then typed into the prompt, or did you use an external editor?

Through cmd.exe, typing:

jrnl 11 january 2016 20:59: Teste de frase com acentuação

for example...

the problem is that you are using windows

@heitorsilva : Set up an external editor and use that to create entries. After you add the entry, _jrnl_ will try and print them to the commandline, but may throw up a similar error (depending on the code page your CMD is set to), but the entry should be there. To confirm this, run jrnl -1 --edit, which will pull up your last entry in the editor.

It's a bit of an ugly workaround, but should do the trick.

Hi @heitorsilva,

I'm using Cygwin terminal on Windows and that fix the problem for me.
(Using CP1252 Character set)
capture_cygwinconf

Hi @gynl!

Thank you for sharing...

I'll wait the Windows 10 update, that enables the bash terminal inside cmd.exe. Maybe, having a native unix console, it will no longer have encoding issues.

If not, I'll do as you do, until someone finds a way to fix!

@heitorsilva Try setting the code page by running chcp 1252 (for "change code page") before running jrnl, does this help?

It doesn't
image

Hm. Then I'm out of guesses - I'm sorry, I'm not a Windows person :(

@maebert : would running the output through unidecode on Windows be an acceptable solution?

That would ruin the experience for everybody that uses cygwin or a shel that doesn't have that problem though. :-(

I've found a solution myself... On cli.py, by changing this:

args.text = [p.decode('utf-8') if util.PY2 and not isinstance(p, unicode) else p for p in args.text]

To this:

try:
    args.text = [p.decode('utf-8') if util.PY2 and not isinstance(p, unicode) else p for p in args.text]
except UnicodeDecodeError:
    reload(sys)
    sys.setdefaultencoding('utf-8')
    args.text = [p.decode('latin-1') if util.PY2 and not isinstance(p, unicode) else p for p in args.text]

I was able to save a record with accents...

Now, the problem is that when I try to show them on the console, they get like this:
image

When changing the code page to 65001, it works partially:
image

Any suggestions to solve this other problem, of the output?

So, 65001 is the code page for Latin-1 encoding, right? This ultimately seems to be a problem with window's implementation of utf-8, and not something intrinsic to jrnl. I wonder whether there are other solutions in other python-apps for windows?

Actually @maebert, 65001 is utf-8 and 1252 is Latin-1 (ISO-8859-1).

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Is this still relevant with v2.0?

I don't use jrnl for a long time now. I don't know...

I'm also not using Windows anymore, and I don't have one to test easily. I would have to download those Windows VMs and try inside of it.

@heitorsilva No worries. Thanks for taking the time to respond! We'll look into it.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I'm testing with jrnl 2.2 on Windows 10 and not running into this problem.

I'm using a Portuguese pangram (a sentence that contains all letters of the alphabet) from this site successfully:

C:\>jrnl
[Compose Entry; on a blank line, press Ctrl+Z and then Enter to finish writing]

Portuguese test
Luís argüia à Júlia que «brações, fé, chá, óxido, pôr, zângão» eram palavras do português.
^Z
[Entry added to default journal]

C:\>jrnl -n 1
2020-03-07 14:01 Portuguese test
| Luís argüia à Júlia que «brações, fé, chá, óxido, pôr, zângão» eram palavras
| do português.
Was this page helpful?
0 / 5 - 0 ratings