I am having issue with the encoding of script created by Toad.
I had set UTF-8 as encoding in the following 2 places:
File–>General–>default encoding
Scripts–>spool file encoding
I have some functions in the database, some functions have some special character inside, for example, French accent letter ‘é’, when I create function script in Toad(one file per object), the script files of those functions with the special character are in ANSI encoding, for those functions do not have the letter, the script file was generated with UTF-8 encoding, by the way, i verified the encoding by opening the file with Notepad++, which can tell me the encoding.
I have issue with ANSI encoding script file.
Is this a bug or anywhere I didn’t configure? For the functions with special character are supposed to be generated as UTF-8 encoding, other than ANSI. I tested package scripts, got same results. The scripts generated using SQL Developer works fine.
My toad version is Toad for Oracle xpert 64-bit, 12.8.0.49
Thanks Damir, it seems your script works, when i ran it and created the file, opened with notepad++, the encoding is UTF-8. I am pasting a script to create 2 test function here, the difference of the two functions is, one assigning ‘e’ to the returning variable, the other assigns ‘é’ to the returning variable. After the 2 functions created, right click the 2 functions in toad, and create script files, choose 1 file per object, thus you will create 2 files, open them with notepad++, check the encoding in notepad++, the one with ‘é’ is ANSI, the other one with ‘e’ is UTF-8, which will be my problem, i need the script file created consistent with UTF-8 encoding. Here is the script:
CREATE OR REPLACE FUNCTION TEST_UTF8 RETURN VARCHAR2
IS
var_any VARCHAR2(100);
BEGIN
var_any := ‘é’;
RETURN var_any;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END;
CREATE OR REPLACE FUNCTION TEST_UTF8_2 RETURN VARCHAR2
IS
var_any VARCHAR2(100);
BEGIN
var_any := ‘e’;
RETURN var_any;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END;
/
Did you set the encoding drop-down when you right-clicked on the object and selected “Create -> Script”? That Encoding drop-down may be set to ANSI, which would export the scripts using that encoding. You may need to set that to UTF-8 as well.
Thanks John for your response. I still have the same issue now. When right click a object to create scripts, there is no drop-down to let me select encoding. There are only 2 places I found in option setting(mentioned in this post), where I already set to utf-8.
When I select more than 1 objects to export, some are exported as utf-8, some are exported as ansi. The one exported as utf-8 with special character cannot be read properly in notepad++.
Thanks a lot, jdorlon, my toad is 12.8, the trick works. Once i did the trick, it seems toad remember it, and the scripts generated has consistent encoding now.