-
Notifications
You must be signed in to change notification settings - Fork 24
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
Unicode, UTF-8, character encodings #1
Labels
Comments
The problem arises when saving Unicode characters in the database. Below is an example. In the database, instead of Unicode characters get "?". Could you help me to solve this problem? import de.bezier.data.sql.*;
import java.io.*;
static String user = "root";
static String pass = "root";
static String database = "test";
static String table = "test";
MySQL msql;
void setup() {
size(1024, 600);
msql = new MySQL( this, "localhost:8889", database, user, pass );
// Тестировании записи данных в базу
if ( msql.connect() ) {
msql.execute("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
msql.execute( "CREATE TABLE IF NOT EXISTS " + table + " ("+"id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, TWEET TEXT) default charset=utf8 ENGINE = MyISAM");
msql.execute("SET NAMES utf8");
msql.execute("INSERT INTO `test`.`test` (TWEET) VALUES ('Тестировании')");
}
exit();
}
void draw() {
} |
ghost
assigned fjenett
Dec 25, 2013
I hope you already found a way around it. public class MySQL_UTF8 extends SQL
{
public MySQL_UTF8 ( PApplet _papplet, String _database )
{
// should not be used
}
public MySQL_UTF8 ( PApplet _papplet, String _server, String _database, String _user, String _pass)
{
super( _papplet, _server, _database, _user, _pass );
init();
}
private void init ()
{
this.driver = "com.mysql.jdbc.Driver";
this.type = "mysql";
this.url = "jdbc:" + type + "://" + server + "/" + database + "?useUnicode=yes&characterEncoding=UTF-8";
}
public String[] getTableNames ()
{
if ( tableNames == null )
{
tableNames = new ArrayList<String>();
query( "SHOW TABLES" );
while ( next() ) {
tableNames.add( getObject("Tables_in_"+database).toString() );
}
}
return tableNames.toArray(new String[0]);
}
} |
Thanks |
fjenett
pushed a commit
that referenced
this issue
Jan 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure this is taken account for:
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-charsets.html
... there have been complaints about characters not showing up correct in Processing sketches. Review these and make tests to ensure it's not on our side.
The text was updated successfully, but these errors were encountered: