Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Umlaute for creditor and debtor #364

Closed
vanvuongngo opened this issue Feb 12, 2022 · 8 comments · Fixed by #367
Closed

Fix: Umlaute for creditor and debtor #364

vanvuongngo opened this issue Feb 12, 2022 · 8 comments · Fixed by #367
Labels
bug Something isn't working

Comments

@vanvuongngo
Copy link
Contributor

vanvuongngo commented Feb 12, 2022

Hi,

thanks for your awesome project. I tried it out and can not get it work with Umlaute, e.g. in location or address.

How to reproduce ...

  • Set PDF(data) like:
creditor: {
    city: "Zürich",
},
debtor: {
    address: "Bürstrasse 1",
const pdf = new PDF(data, "qrbill.pdf", () => {
  console.log("PDF has been successfully created.");
});
  • Then Scan the QR code with your ebanking
    output: Zürich
@schoero
Copy link
Owner

schoero commented Feb 13, 2022

Hi

If you follow the QR-Bill specifications (page 25) exactly, umlauts are actually not allowed.

However, many other QR Bill generators and banks support the umlauts anyway. In fact, I was not aware of any bank that does not support umlauts, and all the banks I have tested support them as well, so I decided against strictly enforcing this rule.

If you really want to be on the save side, you should convert the umlauts for example from Zürich to Zuerich.

Maybe I could add an option in the next version to convert them automatically.

@vanvuongngo
Copy link
Contributor Author

Hi @schoero,

thanks for your quick response. I am wondering why umlauts should not be allowed. What I unterstand on page 25 is that umlauts are not allowed for field definitions and I want to use umlauts in values not in the field definition. Additional the QR code has to be in latin character set which allows umlauts or not? There are multiple example in the specifications with umlauts in the value (page 38, 43, 45 - Max Muster & Söhne).

My bank supports umlauts. I know it because I successfully use the postfinance QR generator with umlauts.

Your generator seems to have a different encoding. Are you sure that your QR-Code has the utf-8 encoding?

@schoero
Copy link
Owner

schoero commented Feb 14, 2022

Thank you for your feedback. I think you are probably right. I have to look into this, but I don't expect to have time to do so until the weekend.

@schoero
Copy link
Owner

schoero commented Feb 15, 2022

Just a quick feedback as I have been doing some research on this topic and I wanted to share my findings:

I decoded a QR code generated by the PostFinance generator and noticed extra bytes 71 a4 00... at the beginning.
By default, a QR code does not encode or transform any data. This means that the string (or bytes) you enter are also the bytes that the reader reads.
If the PostFinance reader treated the read-in data as utf-8 encoded bytes, it would already support umlauts.

However, in the QR code, different modes can be set and one of these modes allows us to " enforce" the encoding. This mode is called "Extended Channel Interpretation" ECI for short and I found some great documentation on this here starting on page 16. These modes are then set with the extra bytes mentioned above.

Apparently the PostFinance generator uses this mode to specify the encoding, and the PostFinance reader depends on this information.

Unfortunately, the library I used (and all other libraries I found) to generate the QR code does not support this mode. However, at first glance I think I could implement this myself with manageable effort.

I just wanted to let you know in case you are doing some research yourself.

@vanvuongngo
Copy link
Contributor Author

vanvuongngo commented Feb 16, 2022

Great catch @schoero, thanks for your research and it sounds promising. I only used the PostFinance generator to generate QR code before and scanned it within another bank. So it seems to me that it's some kind of standard what you figured out.

@schoero
Copy link
Owner

schoero commented Feb 19, 2022

Hi @vanvuongngo
I ended up changing the QR-Code library #367 because I have found one that supports the ECI segments and seems to be written very well.

I have published a beta version, which uses the new QR-Code library. You can install it using the following command:

npm i swissqrbill@beta

Could you please test if the new version now properly gets decoded using the PostFinance scanner? If you have access to any other ebanking or scanners, I would be happy if you could test them as well because I want to ensure that this change does not affect any other bank.

So far I have testet it in the following ebanking apps:

  • Raiffeisen
  • ZKB

@vanvuongngo
Copy link
Contributor Author

H @schoero,
tip top :) and it works with my ebanking apps:

  • BKB
  • migros bank

@schoero
Copy link
Owner

schoero commented Feb 21, 2022

Thank you for testing, I have released the new version v3.1.5 on npm.

@schoero schoero added the bug Something isn't working label Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants