1

This Japanese character , which has four bytes, is saved as ???? in Oracle database whereas other Japanese characters are saved properly.

The configuration in boot.rb of my rails application contains:

ENV['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'

and sqldeveloper of oracle db has

NLS_LANGUAGE    AMERICAN
NLS_TERRITORY   AMERICA
NLS_CHARACTERSET    JA16SJISTILDE

The datatype of the column is NVARCHAR2.

sawa
  • 165,429
  • 45
  • 277
  • 381
OmK
  • 89
  • 8
  • When your column type is `NVARCHAR2` then `NLS_NCHAR_CHARACTERSET` applies, not `NLS_CHARACTERSET`. – Wernfried Domscheit Nov 13 '17 at 13:26
  • Thanks! NLS_NCHAR_CHARACTERSET is AL16UTF16 – OmK Nov 13 '17 at 13:33
  • What do you get from `select UNISTR('\D842\DFB7') from dual;`? What do you get when you select `DUMP(, 1016) from ...`? – Wernfried Domscheit Nov 13 '17 at 14:03
  • Can you do this without Ruby/Rails? – Kris Nov 13 '17 at 14:31
  • select DUMP(, 1016) returns **Typ=1 Len=10 CharacterSet=AL16UTF16: 0,4e,0,61,0,6d,0,65,0,20** and select UNISTR('\D842\DFB7') from dual returns **** – OmK Nov 14 '17 at 06:04
  • Ensure that your ruby-on-rail is entirely set to UTF-8, perhaps these help you: https://stackoverflow.com/questions/5908774/set-global-default-encoding-for-ruby-1-9 https://stackoverflow.com/questions/7699018/in-ruby-on-rails-are-encoding-utf-8-and-config-encoding-utf-8-differe https://stackoverflow.com/questions/20521371/set-utf-8-as-default-for-ruby-1-9-3 – Wernfried Domscheit Nov 14 '17 at 08:09

1 Answers1

2

Try NLS_LANG=AMERICAN_AMERICA.AL32UTF8

Oracle Character set UTF8 is actually CESU-8 whereas AL32UTF8 is commonly known UTF-8

If you stay in Basic Multilingual Plane (BMP) then UTF8 and AL32UTF8 are equal, however when you have characters above U+FFFF then they are different.

is U+20BB7 which is Supplementary Ideographic Plane

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • Tried but didn't work. Any other encoding higher than this which will cover other characters in Supplementary Ideographic Plane? – OmK Nov 13 '17 at 13:34