It is like you are still opening the file with fopen_nchar. If I do this:
create table t42(str nvarchar2(20));
insert into t42 values ('Hello');
declare
file utl_file.file_type;
l_str nvarchar2(20);
begin
select str into l_str from t42;
file := utl_file.fopen('<directory>', 'dummy.dat', 'w', 32767);
utl_file.put_line(file, convert(l_str, 'WE8MSWIN1252', 'AL16UTF16'));
utl_file.fclose(file);
end;
/
... then I get a file containing 䡥汬that the Linux command filereports as UTF-8 Unicode text; Notepad ++ shows 䡥汬and says that the file is ANSI as UTF-8.
If I changed the value fopento fopen_nchar:
file := utl_file.fopen_nchar('CENSYS_EXPORT_DIR', 'dummy.dat', 'w', 32767);
... then I get ORA-29298: Character set mismatchand an empty file.
fopen, PL/SQL varchar2:
declare
file utl_file.file_type;
l_str varchar2(20);
begin
select str into l_str from t42;
file := utl_file.fopen('<directory>', 'dummy.dat', 'w', 32767);
utl_file.put_line(file, convert(l_str, 'WE8MSWIN1252', 'AL16UTF16'));
utl_file.fclose(file);
end;
/
... ¿¿ ( vim), ISO-8859 text. Notepad ++ ߿ , ANSI.
, convert, Oracle , raw:
declare
file utl_file.file_type;
l_str varchar2(20);
begin
select str into l_str from t42;
file := utl_file.fopen('<directory>', 'dummy.dat', 'w', 32767);
utl_file.put_line(file,
utl_raw.cast_to_varchar2(utl_raw.convert(utl_raw.cast_to_raw(l_str),
'ENGLISH_UNITED KINGDOM.WE8MSWIN1252', 'ENGLISH_UNITED KINGDOM.UTF8')));
utl_file.fclose(file);
end;
/
Linux, Hello, ASCII text; Notepad ++ Hello, , ANSI. , , ... , , .
- AL32UTF8, - AL16UTF16, ; WE8MSWIN1252, ; :
UTL_FILE , , UTL_FILE.FOPEN . , UTL_FILE.FOPEN_NCHAR , UTF8 .