How can I get the Japanese character displayed correctly in the oracle database

I know that the oracle database has two character sets: NLS_NCHAR_CHARACTERSET and NLS_CHARACTERSET .

I installed them as:

 NLS_CHARACTERSET WE8MSWIN1252 NLS_NCHAR_CHARACTERSET UTF8 

when i create the database.

I am also creating a use of my table NVARCHAR not VARCHAR , so it is assumed that it will be saved using UTF8 :

 ID NUMBER EMAIL NVARCHAR2(255) USER_NAME NVARCHAR2(255) POST_AT DATE CONTENTS NVARCHAR2(255) 

However, I cannot get the correct results. When I insert strings containing Japanese characters, it simply prints out like "???" when I check it on the terminal.

I do not know why it does not work. Does anyone know a method to solve this problem?

Also, if I don't care how it is stored in the database, just want to get the correct output after retrieving from the database, is there any way to decode it correctly? (I tried several methods for encoding conversion, but did not work)

I am using PHP OCI8 to access the database. oracle database version is oracle 11gR2 for linux.x64

+4
source share
2 answers

If all else fails, you can http://php.net/manual/en/function.base64-encode.php line before inserting and decoding after extraction. Worst case.

+1
source

Thanks for the help. I cannot solve this problem in the end without updating the database and reset the character set ... one thing that I found out is that when creating the oracle database you need to REVERSE the initial setting ...

0
source

Source: https://habr.com/ru/post/1499271/


All Articles