Problems with NLS_CHARACTERSET WE8ISO8859P1 and UTF8 in Oracle

I am currently using a database in oracle that has NLS_CHARACTERSET WE8ISO8859P1, so I will say that I am storing the value in a varchar2 field which is maž (accented character), so in the database it is stored as maå¾. Now when I try to retrieve it using a select * query from a table where fieldValue = 'maž' it returns 0 rows and then when I try to insert it again it gives me a constraint error saying the value already exists.

How to overcome this situation. I am doing this using Java code

+3


source to share


1 answer


http://docs.oracle.com/cd/B19306_01/server.102/b14225/ch2charset.htm#g1009784

Oracle Character Set Name: WE8ISO8859P1
Description: European 8-bit ISO 8859 Part 1
Region: WE (Western Europe)
Number of bits used to represent a character: 8

On the other hand, UTF-8 uses multiple bytes to store a character.

If your database is using WE8ISO8859P1 and the column type is from the VARCHAR group (not NVARCHAR) and you insert a character whose code is> 255, that character will be converted to WE8ISO8859P1 and some information will be lost.



Simply put, if you insert UTF-8 into a db with a single byte character set, your data is lost.

The link above describes various scenarios on how to solve this problem.

You can also try the Oracle asciistr

/ functions unistr

, but in general this is not a good way to deal with such problems.

+1


source







All Articles