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

Invalid character caused by utf8_encode #117

Open
maisoui opened this issue Oct 7, 2021 · 9 comments
Open

Invalid character caused by utf8_encode #117

maisoui opened this issue Oct 7, 2021 · 9 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@maisoui
Copy link
Contributor

maisoui commented Oct 7, 2021

Hi,

My xml contains invalid characters due to the use of utf8_encode in method Data::getContent().
Example : "München" becomes "München" and request will be rejected by bank server.

Is it really necessary to use utf8_encode?

Best regards

@andrew-svirin
Copy link
Member

I think that this utf8_encode is used because XML encoding is utf8.

@andrew-svirin
Copy link
Member

@maisoui if you find, that utf8_encode is breaking the request, then I think we can remove encoding.

@maisoui
Copy link
Contributor Author

maisoui commented Oct 7, 2021

In case of code and passed string is already in unicode, utf8_encode will break the request.
I will try to add an encoding detection before utf8_encode.

@andrew-svirin
Copy link
Member

No need. Because we generating document in the code. Thus we already know it encoding.

@andrew-svirin
Copy link
Member

This utf8_encode was added specially for values with umlauts.

@maisoui
Copy link
Contributor Author

maisoui commented Oct 7, 2021

I guess this litlle snippet can do the job.

//ensure content is unicode encoding
if (!mb_check_encoding($content, 'UTF-8')) {
$content = utf8_encode($content);
}

(will be included in my incoming pull request)

Regards

@andrew-svirin
Copy link
Member

Better to shift the logic for encoding values into Transfer document builder.

@andrew-svirin andrew-svirin added bug Something isn't working good first issue Good for newcomers labels Oct 7, 2021
@maisoui
Copy link
Contributor Author

maisoui commented Oct 7, 2021

agree

@andrew-svirin andrew-svirin added enhancement New feature or request and removed bug Something isn't working labels Dec 8, 2021
@linushstge
Copy link
Contributor

linushstge commented Feb 5, 2022

fixed in #146 :)

Tested with real transactions for all umlauts:

Max Mußtermann
Ää-Öö-Üü-Custom-Name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants