MySQL Collation
- PaP
- Venus Project Founder
- Posts: 1077
- Joined: Wed Apr 21, 2004 12:06 am
- Academic status: Alumnus/a
- Location: San Francisco
- Contact:
MySQL Collation
Χρόνια πολλά σε όλους καταρχήν.
Το πρόβλημα μου είναι ότι θέλω να επεργάστω μέσω Java κείμενο από ένα forum. To collation της βάσης είναι latin1_general και φυσικά τα ελληνικά φαίνονται σαν κάτι τέτοιο ας πούμε åñãáóéá αλλά όταν από τον browser βάλει ς encoding ISO-8859-7 όλα καλά. Το θέμα είναι ότι όταν συνδέομαι στη βάση με Java δεν μπορώ με τίποτα να φτιάξω ένα string με αυτό το encoding και να μπορώ να επεξεργαστώ τα ελληνικά...
Any ideas ?
Το πρόβλημα μου είναι ότι θέλω να επεργάστω μέσω Java κείμενο από ένα forum. To collation της βάσης είναι latin1_general και φυσικά τα ελληνικά φαίνονται σαν κάτι τέτοιο ας πούμε åñãáóéá αλλά όταν από τον browser βάλει ς encoding ISO-8859-7 όλα καλά. Το θέμα είναι ότι όταν συνδέομαι στη βάση με Java δεν μπορώ με τίποτα να φτιάξω ένα string με αυτό το encoding και να μπορώ να επεξεργαστώ τα ελληνικά...
Any ideas ?
- Einherjar
- Venus Project Founder
- Posts: 3751
- Joined: Tue Jan 27, 2004 4:42 pm
- Academic status: Alumnus/a
- Gender: ♂
- Location: Washington DC, USA
- Contact:
μπορείς να φτιάξεις ένα string με το encoding που θες χρησιμοποιώντας έναν συγκεκριμένο κατασκευαστή που λέει:
Αν θες στη συνέχεια να αλλάξεις το encoding μπορείς να κάνεις
Σου κάνει αυτό?
Code: Select all
String
public String(byte[] bytes,
String charsetName)
throws UnsupportedEncodingException
Constructs a new String by decoding the specified array of bytes using the specified charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array.
The behavior of this constructor when the given bytes are not valid in the given charset is unspecified. The CharsetDecoder class should be used when more control over the decoding process is required.
Parameters:
bytes - the bytes to be decoded into characters
charsetName - the name of a supported charset
Throws:
UnsupportedEncodingException - If the named charset is not supported
Since:
JDK1.1
Code: Select all
byte[] result = str.getBytes(targetEncoding);
[Better to understand a little than to misunderstand a lot]
- Swtos
- Kilobyte level
- Posts: 309
- Joined: Mon Apr 18, 2005 4:52 pm
- Academic status: MSc
- Gender: ♂
- Location: Δ.Π
Καλησπέρα κ απο μένα!
Έχω μια βάση MySQL με collation utf8_general_ci και προσπαθώ να φτιαξω ένα interface(σε PHP αν εχει σημασία) που να επικοινωνει με αυτη. Η βαση εχει ελληνικά μεσα τα οποία όμως μου τα εμφανίζει ως ??????. Εχω δοκιμασει και το ISO-8859-7 αλλα τιποτα! Καμία ιδέα;
Έχω μια βάση MySQL με collation utf8_general_ci και προσπαθώ να φτιαξω ένα interface(σε PHP αν εχει σημασία) που να επικοινωνει με αυτη. Η βαση εχει ελληνικά μεσα τα οποία όμως μου τα εμφανίζει ως ??????. Εχω δοκιμασει και το ISO-8859-7 αλλα τιποτα! Καμία ιδέα;
-My father made him an offer he couldnt refuse
-What was that?
-Luca Brasi held a gun to his head and my father assured him that either his brain or his signature would be on the contract
-The Godfather
-What was that?
-Luca Brasi held a gun to his head and my father assured him that either his brain or his signature would be on the contract
-The Godfather
- PaP
- Venus Project Founder
- Posts: 1077
- Joined: Wed Apr 21, 2004 12:06 am
- Academic status: Alumnus/a
- Location: San Francisco
- Contact:
Θα πρέπει η HTML που παράγεις αν έχει εντολή για utf-8 collation
Δηλαδή:
Δηλαδή:
Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />