hledger icon indicating copy to clipboard operation
hledger copied to clipboard

hledger-web on Windows shows pounds sterling symbol as "£" - unicode issue

Open hymerman opened this issue 7 years ago • 24 comments
trafficstars

Anywhere the pounds sterling symbol is meant to be shown in the web interface, "£" is shown instead. It's this way in the page source. Hledger on the console is fine.

This has been happening for a long time (years), on all machines I've tried it on (Windows 7 and Windows 10). I'm a bad person for not reporting it until now!

E.g. image

hymerman avatar Feb 12 '18 15:02 hymerman

Thanks for the report. I don't see this on mac or linux. Can any other windows users confirm ? How are you starting hledger-web ? How is your journal file encoded ? (Not sure how to check this on windows, on unix it's file FILE).

simonmichael avatar Feb 12 '18 16:02 simonmichael

No problem - thanks for the quick response!

I'm starting like this (using mingw64 provided with Git for Windows, but the same bug happens starting through Windows standard command prompt too):

hledger-web.exe --file=/path/to/my.ledger

The journal file is encoded in UTF-8, with Windows (CRLF) line endings.

I'm using the binary from AppVeyor artifacts.

hymerman avatar Feb 12 '18 16:02 hymerman

Is it the same if you double click hledger-web.exe ? (You might need to create a journal file in default location eg with hledger add).

Does the data entry mechanism matter ? Eg compare entry through hledger-web, hledger add, and a text editor.

simonmichael avatar Feb 12 '18 16:02 simonmichael

I just tried creating a new journal with hledger add, and double clicking hledger-web. Same result - shows "£". I can't figure out how to add transactions in the web interface, it doesn't do anything or give any error after clicking "Add". But now I've tried through hledger add, and just by reading a text file.

Entries in the text file look like this:

1999/06/30 Gross interest
    assets:savings:Nationwide  £1.17
    income

hymerman avatar Feb 12 '18 17:02 hymerman

Thanks for testing. Hmm, odd that you have no add form in hledger-web. I would expect at least a js error visible in web inspector. I suspect the appveyor binaries are not up to date.

simonmichael avatar Feb 12 '18 17:02 simonmichael

Ah sorry, I wasn't clear - the add form shows, but the 'Add' button at the bottom of the form didn't appear to actually add the transaction, just clear the form. Also I was trying this on an old version from AppVeyor since there's another bug I haven't reported yet (want to anonymise my data first) which prevents me using it (ignores lots of transactions) - but this bug (the £ one) does apply to the most recent AppVeyor version too! Sorry if that's caused any confusion - I'm a developer myself so I know the frustration caused by bug reporters hiding details ;)

hymerman avatar Feb 12 '18 17:02 hymerman

Ok good to know. :) I think I'll need someone on windows to debug this.. I don't currently have access to a windows machine, aside from appveyor..

simonmichael avatar Feb 12 '18 17:02 simonmichael

Though, if debug-me builds on windows, I/we could do a little remote GHCI debugging.

simonmichael avatar Feb 12 '18 22:02 simonmichael

I'm not experienced with Haskell - I tried building hledger on Ubuntu a year ago (following the docs to the letter) and it took me an hour and I still failed... I don't think I can justify spending that much time on this given how minor it is, sorry!

hymerman avatar Feb 13 '18 11:02 hymerman

Unfortunately I have to use windows at work, and it would be handy to update/inspect etc. my ledger whilst on my work computer. I seem to have the same issue as OP, specifically:

If I add a transaction via hledger add in CMD.exe, then open the file in VS Code or some editor is shows œ or � instead of £. If I view my journal via hledger then it shows £ as I originally typed. Likewise, if I edited the journal in VS Code and add £, when viewing in hledger it shows ┬ú.

I tried powershell but that does the same thing. If I stick with one or the other it's okay but I can't mix them.

If I add a transaction in linux - via text editor or hledger add - then the £ symbol shows fine in VS Code on windows but shows as ┬ú in hledger in CMD.exe.

I'm fine skipping hledger add in windows and probably its a windows thing rather than hledger.

alexjj avatar Aug 06 '21 10:08 alexjj

This may be related to #1619. Would it be possible to upload some copies of the actual files you've created, so we can see the character encoding? Just start with a blank journal, and send different copies where you've added the transaction in different ways.

Xitian9 avatar Aug 06 '21 10:08 Xitian9

Just as a shot in the dark, can you checkout this branch and see if you still have the same issue? https://github.com/Xitian9/hledger/tree/notextio

Xitian9 avatar Aug 06 '21 11:08 Xitian9

I had to make them .txt files else github complains:

Made with hledger add in windows CMD.exe windows-cmd.journal.txt

Made in vs code on windows: vscode-windows.journal.txt

Here are the files pre-converted to txt in case windows does something else stupid. hledger.zip

alexjj avatar Aug 06 '21 11:08 alexjj

Just as a shot in the dark, can you checkout this branch and see if you still have the same issue? https://github.com/Xitian9/hledger/tree/notextio

If you can build a windows binary for me....afraid I can't install many things on my work computer.

alexjj avatar Aug 06 '21 11:08 alexjj

The vscode-created file is correctly encoded in utf-8, while the windows-cmd file is in an unknown character encoding which I can't identify. Can you please follow the instructions here in cmd.exe, and let us know what it reports for you system locale and input locale?

Xitian9 avatar Aug 06 '21 11:08 Xitian9

The vscode-created file is correctly encoded in utf-8, while the windows-cmd file is in an unknown character encoding which I can't identify. Can you please follow the instructions here in cmd.exe, and let us know what it reports for you system locale and input locale?

System Locale:             en-us;English (United States)
Input Locale:              en-gb;English (United Kingdom)

hmm need an IT Admin to change system locale...🙄

alexjj avatar Aug 06 '21 12:08 alexjj

Hmm, not sure what to do at this stage. I would be interested in knowing if the branch I sent works, but I can't compile it for Windows myself.

Xitian9 avatar Aug 06 '21 13:08 Xitian9

Hmm, not sure what to do at this stage. I would be interested in knowing if the branch I sent works, but I can't compile it for Windows myself.

I wonder if this tick box helps... image

I may be able to do it on another computer later to see. Personally I can skip using hledger add on my work computer. I can edit in editor or just remote to my home computer and use it on there. It was just a nice to have. Thanks for your help.

alexjj avatar Aug 06 '21 13:08 alexjj

The usual outcome of these windows encoding issues is "just don't mix environments" - ie, use shells/command prompts/software compiled in and for just the one environment, whether that is the old command prompt, powershell, MINGW, MSYS2, WSL, ... (I forget their names). As long as you follow that rule, hledger should work as well on Windows as on other platforms, pretty much.

In this case it sounds like CMD/powershell aren't encoding-compatible with the VS Code build you're using. From past experience, without a dedicated Windows developer we won't be able to do much about that. I would try a WSL shell, or the terminal pane inside VS Code ?

simonmichael avatar Aug 06 '21 20:08 simonmichael

It's CMD/Powershell or some Windows global setting or whatever. It works fine between Linux and VS Code on Windows.

alexjj avatar Aug 06 '21 20:08 alexjj

Hi there, @alexjj, I faced the same issue on Windows 11 and actually checking 'Beta: Use Unicode UTF-8 for worldwide language support' helped to resolve the issue. hledger 1.31-g7fbe76970-20230903, windows-x86_64 image

vladimir0ne1 avatar Oct 21 '23 15:10 vladimir0ne1

@hymerman , @alexjj let us know if it works for you when you get a chance.

simonmichael avatar Oct 21 '23 16:10 simonmichael

Hi, I also have this issue using hledger 1.32.1-g39fc78a64-20231207, windows-x86_64

.hledger.journal (UTF-8 encoded)

; journal created 2023-12-16 by hledger
2023-12-16 Caractères accentués
    actifs:argent de poche  3,00 €
    capitaux propres

hledger areg actifs produces the following output:

Transactions in actifs and subaccounts:
2023-12-16 Caract├¿res accen..  capitaux propres          3,00 Ôé¼      3,00 Ôé¼`

hledger-web also shows Ôé¼ instead of

dannyhpy avatar Dec 16 '23 00:12 dannyhpy