-
Notifications
You must be signed in to change notification settings - Fork 6
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
UTF-16 and UTF-8 encoding error in XmlImporter #9
Comments
Oops sorry this should be in the Marc project as it is a Marc issue, I am going to post a new Issue on Marc project. |
Just realized that I haven't made a release in a while, so the version on Packagist was quite outdated. I pushed version 0.7.0 now, which contains a lots of changes, most of which should be documented in the changelog. Among other things, I have switched from using JSON to XML when it comes to the Bib API. One reason is the annoying UTF-16 thing, which is only present when using JSON. More importantly, though, updating a record only works when using XML. Update: Wait, it seems like I also used XML in version 0.6.1. Anyways, please try the latest version and see if the issue is still there. If it is, can you check if you get UTF-16 if you request the same record using curl?
In my case, I get UTF-8 as long as I use |
Still a problem in 7.1. Note, the problem is not that Alma sends out UTF-16 - it never does. However, sometimes it claims that the UTF-8 it sends out is really UTF-16. |
@krifro , I'm aware that Alma sends the wrong encoding when requesting json, but I have never observed it when requesting xml, which is what php-alma-client has done since version 0.7.0. Can you please provide a minimal example that reproduces the problem? Or is it not reproducable? |
@danmichaelo: I'm not used to github, so I'm sorry if I shouldn't be doing this inline or something. composer.json: My project requires php 5.*, so I'm using 5.6.37 and needed to use options-resolver 3 rather than 4. test.php:
I've tried this against two alma instances, using two different computers and three different operating systems, with different languages, but I keep getting:
I can iterate over the holding's items and from them fetch stuff like the holding ID, but fiddling with the holding itself breaks. |
Aaah, holding records! I rarely work with those myself, so I probably forgot to test them. Will fix! |
@krifro , give 0.7.2 a try 🚀 |
I'll do so come Monday, I don't have access from home. Thank you for looking into this so fast! :) Edit: Tested, works! The framework can now fetch and parse a Holding record. Unfortunately, we still won't be able to use the framework, it seems:
|
XmlImporter will trigger an error while reading xml depending on the version of Alma.
Alma might return an XML document in the wrong encoding, encoding in XML file is said to be UTF-16 but actually it is UTF-8.
A solution is to catch this error, then change the encoding in the XML using a preg_replace from UTF-16 to UTF-8 and then parse the XML file.
See attached XMLImporter file
XmlImporter.php.zip
The text was updated successfully, but these errors were encountered: