ebics-client-php icon indicating copy to clipboard operation
ebics-client-php copied to clipboard

Invalid character caused by utf8_encode

Open maisoui opened this issue 3 years ago • 9 comments

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

maisoui avatar Oct 07 '21 12:10 maisoui

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

andrew-svirin avatar Oct 07 '21 12:10 andrew-svirin

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

andrew-svirin avatar Oct 07 '21 12:10 andrew-svirin

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.

maisoui avatar Oct 07 '21 12:10 maisoui

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

andrew-svirin avatar Oct 07 '21 12:10 andrew-svirin

This utf8_encode was added specially for values with umlauts.

andrew-svirin avatar Oct 07 '21 12:10 andrew-svirin

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

maisoui avatar Oct 07 '21 12:10 maisoui

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

andrew-svirin avatar Oct 07 '21 13:10 andrew-svirin

agree

maisoui avatar Oct 07 '21 13:10 maisoui

fixed in #146 :)

Tested with real transactions for all umlauts:

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

linushstge avatar Feb 05 '22 13:02 linushstge