Is there any way to tell JSoup to post data using iso-8859-1 rather than utf-8 ?
I tried posting a parameter that contains the letter 'è' the my webserver receives the character with hex code C3A8 but I want to send E8.
The code I wrote is
Document document = Jsoup.connect("https://somesite.com/test") .data("parameter1","\u00E8").
header("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")
.method(Method.POST)
.execute()
.parse();
As already said, on the other hand I get a 2 bytes data (C3A8) rather than a single byte with E8 inside.
Thanks in advance for your help.
Trying to replicate a successful POST request with JSoup - data posted to server does not get decoded
Has an accepted answer, saying it is not possible to do it. You will have to find a way to post your code into utf-8. If you do not succeed in that, just open a new question about it.
Related
Exact text written on admin panel is Test’s, and our PHP server is using utf8_encode() method to encode this text, which results in response on mobile end like ::
Test\u00e2\u0080\u0099s
How could I decode it back to ’ to display on mobile app ?
I have tried so many solutions given including utf8 decoding, but it's not working, please help.
I also tried solution given in How to replace the \u00e2\u0080\u0099 this string into ' in iOS, but this solution is for only a specific character, and I am looking for some generalize solution, replacement of \u00e2\u0080\u0099 with ’ seems to be a temporary solution as it don't assure if I get some other unicode in response.
As per the OP...
The problem was with the server encoding, and not on the decoding end.
I'm adding this as an answer so other folks don't have to dig through the comments.
I tried to use Unicode characters in my FTP server's greeting, but the client seems to read them as two different characters each. Because of this, I need a way to encode them into UTF-8. For now, I have the greeting HTML encoded because I am displaying it on a webpage, but on any other client it will display the encoding. How can I set the greeting to be parsed as UTF-8? And if I can't, then is there a way I can parse the greeting correctly?
EDIT: Answered my own question, see below.
I found the answer to the question. It was actually UTF-8 encoded already, and I had to decode it from UTF-8. Here is what I did:
decodeURIComponent(escape(greeting))
Don't forget to replace the line breaks with <br> if you are displaying it on a webpage like I am!
decodeURIComponent(escape(greeting)).replace(/\n/g,'<br>')
I want to get xml string from url "http://test.php?value=xxx",here xxx shall be in XML format,for example:<request><command>test</command></request>.After I post this,the server will give me a result with xml string.But i don't know how to do that.Anyone has a solution?Thanks.
http://www.raywenderlich.com/30445/afnetworking-crash-course
That website gives you a step by step exactly what you need with AFNetworking. The question you are asking is very vague. If you get more specific then I can give direct code. Otherwise that crash course website is very informative.
I've made an iPad app that posts data to a ASP script. Data is then stored in UTF-8 in the MySQL db. Today one of the users posted data which made an error:
Data posted:
Jeanette Sjösvärd, Uttke Renata, Håkan Giljam
Data saved in log and db:
Jeanette Sjösvärd, Uttke Renata, Håkan Giljam
When reading data from the database, the text is full of "Ã¥ ä ö" (should be "å ä ö")
The log also saves the original post data the way it arrives to the server in percentage format:
Jeanette%20Sj%C3%B6sv%C3%A4rd%2C%20Uttke%20Renata
When posting all the data again (copy and paste that percentage-encoded block) from an ASP page, the data gets saved without any encoding issues.
Facts
Full posted data is about 18kB
All ASP pages contains <%#LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> on top
Questions/ideas
Why does the ASP script read the data in different ways, depending on the sender?
Why did it just happen 1 out of 100 times?
Is there any encoding information that is/should be sent along with a POST request?
Could it be depending on some single special character in the data?
Does the iPad use any other encoding than UTF-8 as a standard? (The iPad is set to Swedish)
Edit
Found this thread: What determines the encoding of then data you receive from an HTTP POST?
Will look into the encoding header of the post request. But how could I detect if posted data isn't UTF-8 and in that case convert it?
Follow-up in this post: https://stackoverflow.com/questions/15656710/how-to-detect-post-encoding-and-convert-to-utf-8-in-asp
I have the following xml that I would like to read:
chinese xml - https://news.google.com/news/popular?ned=cn&topic=po&output=rss
korean xml - http://www.voanews.com/templates/Articles.rss?sectionPath=/korean/news
Currently, I try to use a luaxml to parse in the xml which contain the chinese character. However, when I print out using the console, the result is that the chinese character cannot be printed correctly and show as a garbage character.
I would like to ask if there is anyway to parse a chinese or korean character into lua table?
I don't think Lua is the issue here. The raw data the remote site sends is encoded using UTF-8, and Lua does no special interpretation of that—which means it should be preserved perfectly if you just (1) read from the remote site, and (2) save the read data to a file. The data in the file will contain CJK characters encoded in UTF-8, just like the remote site sent back.
If you're getting funny results like you mention, the fault probably lies either with the library you're using to read from the remote site, or perhaps simply with the way your console displays the results when you output to it.
I managed to convert the "ä¸ç¾" into chinese character.
I would need to do one additional step which has to convert all the the series of string by using this method from this link, http://forum.luahub.com/index.php?topic=3617.msg8595#msg8595 before saving into xml format.
string.gsub(l,"&#([0-9]+);", function(c) return string.char(tonumber(c)) end)
I would like to ask for LuaXML, I have come across this method xml.registerCode(decoded,encoded)
Under that method, it says that
registers a custom code for the conversion between non-standard characters and XML character entities
What do they mean by non-standard characters and how do I use it?