Summary of special characters

Source: Internet
Author: User

I recently made a project with many special characters, which caused some problems. I was very happy to solve the problem and shared it with others.
Special characters:
Jörg Ranau
Sigut extends Jak %tonyt %
C branch te dIvoire


Manually import data to the database

1: Check whether the character set of the database is consistent with that of the client. UTF8 is used.
View statement:
Select * from nls_database_parameters

2: If SQL plus in DOS is used to import data, set NLS_LANG = AMERICAN_AMERICA.UTF8 is required.
Windows: set NLS_LANG = AMERICAN_AMERICA.UTF8
Unix: NLS_LANG = AMERICAN_AMERICA.UTF8

3: Check the file format of the imported data. The format is UTF8 without BOM,
You can use NOTEPAD ++ and conver to UTF8 without BOM.
You can also use txt to convert it to UTF8.


3rd is very important. I ignored it before and found that the data displayed after the database is inserted into the database is incorrect.

Verify that the imported data is correct by using the oracle dump command.
Select dump (country_desc), country_desc from tb_test where testcode = 1;
Typ = 1 Len = 14: 67,195,180,116,101, 32,100, 118,111,105,114,101, C character te dIvoire


Special characters are encountered in the database script:
1: single quotation marks. The oracle script must be written into two single quotation marks.
UPDATE pi_portal_nday SET ND_CTY = C destination te d 'Ivoire WHERE ND_ID IN (152,162 );

2: Special Character &, oracle indicates the required parameter. If the data contains this two methods:
1st: set define off;

2nd types:
Set escape on;
Then replace all & /&.

3: Empty rows
Use <br> instead.


Import data using JAVA code:


The data to be imported is stored in a TXT file and imported to the database through the batch job.
Check the file format of the imported data. The format is UTF8 without BOM,
You can use NOTEPAD ++ and conver to UTF8 without BOM.

Java code:
1: UTF8 format is used to read files.

InputStreamReader read = new InputStreamReader (new FileInputStream (file), "UTF-8 ");
BufferedReader inBuf = new BufferedReader (read );

2: Check the ENCODING character of the file used by the development tool.
This is why we did not find that the error of reading files has deceived our eyes by using the LOG output in the development tool.

By default, the JAVA file in BEA is ENCODING cp1252 and changed to UTF8. This is especially easy to ignore. when reading the LOG on the console, you find that the content in the file you have read is correct, and the JAVA source file is ignored. The conversion from unicode to utf8 is considered a problem, especially when the characters are processed again, it is found that the database is still incorrect. After the ENCODING character is modified, it is found that the file is incorrect. This is easy to solve. So you only need to modify the UTF8 format when reading the file.


In JAVA code, values are directly assigned or entered on pages.
1: The page is very simple. JSP or HTML, which can contain UTF-8 characters.
2: The code must be converted:
Byte [] byteArr1 = columnValueBe. getBytes ("UTF-8 ");
ColumnValue = new String (byteArr1, "UTF-8 ");

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.