Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding error when importing the selected object #48

Closed
Danieleeee opened this issue Nov 30, 2020 · 8 comments
Closed

Encoding error when importing the selected object #48

Danieleeee opened this issue Nov 30, 2020 · 8 comments

Comments

@Danieleeee
Copy link

When I import a DB package, using the "import selected object" function, the encoding is not respected. You can test using the WE8MSWIN1252 encoding

@true-hb
Copy link

true-hb commented Nov 30, 2020

I've got a similar problem.

I use just a simple Script for testing, stored with win-1252 encoding:

COLUMN parameter FORMAT A20
COLUMN value FORMAT A20
SELECT * FROM V$NLS_PARAMETERS
WHERE parameter IN ('NLS_LANGUAGE', 'NLS_TERRITORY', 'NLS_CHARACTERSET');
SELECT USERENV('LANGUAGE') FROM dual;
SELECT 'ÄÖÜ-äöüß-€' AS umlaute FROM DUAL;

grafik

In oradewrc.json I have
"source.encoding": "win1252",

and in settings.json:

	"files.encoding": "windows1252",
	"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
	"terminal.integrated.shellArgs.windows": "/k chcp 1252",
	"oradew.envVariables": {
		"NLS_LANG": "GERMAN_GERMANY.WE8MSWIN1252"
	}

When I Show NLS_LANG in Dos-Shell:

Z:\>echo %NLS_LANG%
AMERICAN_AMERICA.we8mswin1252

When I use sqlplus.exe in the vscode-Terminal, everything is fine:
grafik

What can I do?

@mickeypearce
Copy link
Owner

Have you tried also setting chcp in the intermediate sql.bat file (cliExecutable) setting?

@Danieleeee
Copy link
Author

Danieleeee commented Dec 1, 2020

I also get the same error (????) and I use the following file.bat

chcp 1252 
set NLS_LANG=.WE8MSWIN1252
sqlplus %*

the file.bat solves the problems of special characters when saving objects in the DB, but not when getting information from the DB.
I think it is related to the problem that I reported above concerning the import of objects from DB.
If the script (file.sql) is written with UTF8 encoding there are no problems. If I use Windows1252, it doesn't work.

@Danieleeee
Copy link
Author

It probably depends on how the task to launch the command is configured.
Take a look here:
Changing the encoding for a task output

@mickeypearce
Copy link
Owner

The oradew task which subsequently runs sql (cli) process is executed through processExecution:

new vscode.ProcessExecution(

I believe that is the reason why shellArgs don't do the trick here and I am not sure if it is possible to pass chcp to terminal used in processExecution and how.

Maybe changing the default code page of the terminal could help:
https://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8

@mickeypearce
Copy link
Owner

Importing with "import selected object" is a different story as it save file on disk (not related to chcp). It should work with correctly setting property ("source.encoding": "win1252").

@Danieleeee
Copy link
Author

I do not recommend you to change the code page of the machine, it may stop the Windows operating system.
Thanks @mickeypearce, I hope that at least it works out for the objects imported from the DB.

@Danieleeee
Copy link
Author

Danieleeee commented Dec 1, 2020

@mickeypearce this is my oradewrc.json:

{
  "compile.warnings": "NONE",
  "compile.force": true,
  "compile.stageFile": false,
  "source.input": ["./Database/**/*.sql"],
  "source.encoding": "win1250",
  "source.pattern": {
    "packageSpec": "./Database/{schema-name}/STOREDS/PKSPEC/{object-name}_h.sql",
    "packageBody": "./Database/{schema-name}/STOREDS/PKBODY/{object-name}_b.sql",
    "trigger": "./Database/{schema-name}/TRIGGERS/{object-name}.sql",
    "typeSpec": "./Database/{schema-name}/TYPES/{object-name}.sql",
    "typeBody": "./Database/{schema-name}/TYPE_BODIES/{object-name}.sql",
    "view": "./Database/{schema-name}/VIEWS/{object-name}.sql",
    "function": "./Database/{schema-name}/STOREDS/FUNC/{object-name}.sql",
    "procedure": "./Database/{schema-name}/STOREDS/PROC/{object-name}.sql",
    "table": "./Database/{schema-name}/TABS/{object-name}_tab.sql",
    "synonym": "./Database/{schema-name}/SYNONYMS/{object-name}.sql",
    "apex": "./Database/{schema-name}/APEX/{object-name}.sql"
  },
  "import.ease": true,
  "import.getDdlFunction": "siu.utl_generate_oradew.getddl",
  "package.input": ["./Database/**/*.sql", "./scripts/**/*.sql"],
  "package.exclude": ["./scripts/**/+(file|run|test)*.sql"],
  "package.output": "./pubblicazione/{schema-name}.sql",
  "package.encoding": "win1250",
  "package.templating": false,
  "test.input": ["./test/**/*.test.sql"],
  "version.number": "0.0.1",
  "version.description": "Gestione DB",
  "version.releaseDate": "2021-01-01"
}

putting "source.encoding": "win1252" the problem is solved. my mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants