Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1226

Questions about encoding between client-server-db

$
0
0

I'm a little confused about encoding.
The basic principle is,
When you create a byte array to send data to the network, you create it by referring to the character set and sending it,
and the receiver decodes the received byte array into their own character set.
In order to send and receive non-ASCII data, it is my understanding that all systems participating in the communication (browser, web, was, db, etc... except for kids like L4) must have the same encoding method so that they can send and receive data without breaking each other.
(If I'm wrong, please let me know)

So here's a little more detail, is this also correct?

  • Client (UTF-8) -> Server (EUC-EN)
    • client's so GET, POST are sent with utf-8 encoding
    • Since the charset of the was server is euc-kr (-Duser.language=en), it will be broken if you just receive the data, so you need to set request.setCharacterEncoding("UTF-8") and read the data to receive the data without breaking it.
  • DB(utf-8) -> server(euc-en)
    • This also results in broken data due to mismatched encoding
    • You need to set jdbc to something like jdbc:mysql://localhost:3306/administer?characterEncoding=utf8 to receive it without breaking it.
  • If there is a string string comparison in the Java , jsp source
    • all of these strings will follow the server's default charcterset.

But..! When I looked it up, I found that Java always encodes to UTF-16 internally (the encoding currently adopted by Java ), and when receiving data with JDBC, it also encodes to UTF-16.

This confused me a lot, so I posted a question.
If this is correct, if I set it like this: jdbc:mysql://localhost:3306/administer?characterEncoding=latin1, will it have no effect?

How far does the server's charset affect it?


Viewing all articles
Browse latest Browse all 1226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>