I'm having troubles with special characters like í, ó, ñ, and so on in my MYSQL database.
I've read a lot about character set, collation, utf and son on but I might not being able to proper apply it to this problem. I'm not sure if the problem is with my tables or when reading the source file and encoding. I'm working on netbeans developing an interface that generates specific reports
Here I briefly explain the process when the issue occurs
There is a table where are located the path files for the Excel files that are requested.
My code takes that path, opens the file using the JXL library.
Then it starts reading every cell that it is indicated in the code and export the data to the tables indicated (HERE IS WHERE IN THE TABLES APPEARS THIS � IN EVERY SPECIAL CHARACTER)
The data is correctly exported to the several tables, and there is no problem with that, only special characters that are replaced with this �
So, after researching I've tried this
As I'm using MYSQL workbench I've alter every table in the collation from utf8 - default TO utf8 - utf8_spanish_ci and utf8 - utf8_spanish_ci
I've tried also changing the collation to utf16 - default collation, utf_spanish_ci, bin, etc
And also, I've tried using the utf32 collation.
The netbeans encoding it is correctly set to utf-8
I've tried exploring the JAVA functions that connects to MYSQL, I'm using this connection but I haven't found nothing about encoding:
private Connection conecta=null;
String Driver="com.mysql.jdbc.Driver";
String Url="jdbc:mysql://XXX.XXX.XXX.XX/BLAABLA";
Class.forName(Driver);
conecta=DriverManager.getConnection(Url,User,Password);
The database when I manually insert data that contains special characters, it correctly displays whenever I need it, but when I try using the automatically insert option as previously described that reads the file using jxl library and so on, then it happens the � thing.
I've found some useful answers here in stackoverflow but all are related to specific cases of php, html, xml and so on. All the answers about java are related to the utf8 collation
So I hope you can provide me some help.
Am I not doing the collation correctly?, Should I try something weird directly in the console? Does mysql workbench is forbidding something?
I'm open to all kind of suggestions but if the answer is like "You must use another library because jxl does not work with that" please consider that my project is almost done, and re-do this with a different library could take me much more time as I already have expected. Please, if JXL is the problem probably there must be something else. Nothing is impossible right?
Thanks for the time.
Excel files by default uses windows-1255 (Cp1255) codification. So when you read those bytes from the excel file you need to treat them with that charset and then store them with utf8.
Related
I need to send a file over FTP (I'm using commons-net Java library) using ASCII mode (can't use Binary mode because the host uses a different way of storing data), but I need the LF characters to stay as LF and not to be transformed to CRLF.
Indeed I need LF to stay as LF and CRLF to stay as CRLF.
So far I couldn't find a way of doing this.
If there is no way of doing this with commons-net but someone knows how to do it with a different library would be appreciated
Thank you all for your responses.
See you
Solution
Finally I had to change to the ftp4j library, which works as I wanted out of the box.
The point of ASCII mode is exactly to have the line ending specific for the platform. So on UNIX system it will be LF and on windows CRLF. There is no way around it inside the client, because the server might convert the data. If you pass the data unmodified there is no way around using binary.
I have a stand alone java program that opens a text file in UTF-8 mode and read each line in the file containing Swedish characters like å, ä, ö. The text file has been saved in utf-8 mode. The java program prints what it reads from the file into standard output and I have verified that the program can read and print these special characters properly. The program then saves this data it read from the file into a Mysql 5.5 database with default utf-8 collation by using a JDBC connection.
Nevertheless, when the program inserts these textual data with the Swedish characters into the mysql database, the special characters are replaced with weird black characters that are not readable. If I change the database collation to latin1 instead, then all these special characters are removed by the MySQL server. I have googled the issue and found suggestions involving the use variations of utf-8 and latin1 as the default database collation but non of them seems to have helped me so far.
I wonder if there is anyone facing a similar issue on placing Swedish characters in a mysql database? If so, could you tell me what is the collation type and charset I should be using to have swedish charecters correctly in the database. Do I have to make a specific setting in JDBC database connection for these letters to be saved correctly? Perhaps the issue is more java related but I verified visually that my java program can read/print these characters properly. Thanks.
I am building an app that takes information from java and builds an excel spreadsheet. Some of the information contains international characters. I am having an issue when Russian characters, for example, are rendered correctly in Java, but when I send those characters to Excel, they are not rendered properly. I initially thought the issue was an encoding problem, but I am now thinking that the problem is simply not have the Russian language pack loaded on my Windows 7 machine.
I need to know if there is a way for a Java application to "force" Excel to show international characters.
Thanks
Check the file encoding you're using is characters don't show up. Java defaults to platform native encoding (Win-1252 for Windows) instead of UTF-8. You can explicitly set the writers to use UTF-8 or Cyrillic encoding.
We recently got a localization file the contains Portuguese translations of all the string in our java app. The file they gave me was a .csv file and I use file maker to create .tab file which is what we need for our purposes. Unfortunately none of the accents seem to work. For example the string vocÍ in our localization file shows up as vocΩ inside the application. I tried switching the language settings to portuguese before creating compiling but I still get this problem, anyone have any ideas of what else I might need to try?
I think that you problem is related to the file encoding used.
Java has full unicode support so there shouldn't be any problems, unless the file you are reading (the one made with FileMaker) is encoded in something different than UTF8 (which is the default used by Java).
You can try saving the file in a different encoding or specifying which encoding to use when opening it from Java (see here). Many API classes support additional parameters to specify which charset to use when opening a file. Just take a look at the documentation..
I have a Java application that is generating JasperReports. It will create as many as three JasperPrints from a single report: one prints on the printer, one is serialized and saved to the database, and the third is exported to PDF using Jasper's built-in export capability.
The problem is that when exporting to PDF, characters containing 8 or more bits (i.e. not 7-bit ASCII) are showing up as empty squares, meaning Acrobat Reader is not able to display that character. The print version is correct, and loading the database version and printing it shows up correctly. If I change the PDF exported version to a different format, e.g. XML, the character shows up fine in a web browser.
Based on the evidence, I believe the issue is something specific to font handling in PDFs, but I am not sure what.
The font used is Lucida Sans Typewriter, a Unicode monospaced font. The Windows "font" directory is listed in the Java classpath: without this step, PDF exporting fails miserably with zero text at all, so I know it is finding the font.
The specific characters not displayed are accented characters used in Spanish text: á, é, í, ó, and ú. I haven't checked ñ but I am guessing that won't work too.
Any ideas what the problem is, areas of the system to check, or maybe parameters I need to send to the export process?
The PDF encoding used for exporting was UTF-8, and apparently the font didn't support that properly. When I changed it to ISO-8859-1, every character showed up correctly in the PDF output.
In iReport, try setting the Pdf Embedded property of your TextFields to true.
I'm using Jasper Report 6, My team has spend a few days to display Khmer Unicode. I have found solution finally, and everything work as expected.
follow this https://community.jaspersoft.com/wiki/custom-font-font-extension
after you exported, upload your jar file to lib folder and restart your jasper server.