rizonesoft / Notepad3

Notepad like text editor based on the Scintilla source code. Notepad3 based on code from Notepad2 and MiniPath on code from metapath. Download Notepad3:
https://www.rizonesoft.com/downloads/notepad3/
Other
4.8k stars 321 forks source link

[Auto Feature Request] autochange codepage by "chcp XXXX" here "chcp 850" if found..... #1743

Closed blackcrack closed 4 years ago

blackcrack commented 4 years ago

Hi,

it should by open text search for "chcp 850" coding if exist, should automatically setting up to OEM 850 code page .

this is good for specially codepages, japan, German, etc. ( mutated vowel äöü and ascii grafic █▓▒ )

Actually does it not search by open document/Text/batch and change not automatically by found "chcp %codepagenumber%".

could you are insert a search/pharse Algorithm, where search for "chcp %codepagenumber%" and setting notepad3 up automatically to the right Codepage ? Then can the users setting up "chcp 850 >NUL" and the codepage it's automatically setted up in Notepad3 like it is setted up in the script as "chcp %1" , here a batchscript where needs in german and with ASCII Signs in codepage 850

here a small listing about codepaghes : https://ss64.com/nt/chcp.html here about codepages https://en.wikipedia.org/wiki/Windows_code_page

best regards Blacky

RaiKoHoff commented 4 years ago

Notepad3 prefers UTF-8 encoding policy (reasons see: http://utf8everywhere.org). If you like to prefer your systems locale ANSI encoding (Notepad3 uses your systems locale settings as default ANSI encoding), just switch the Default Encoding to ANSI (1st entry): (Menu->File->Encoding-Set Default...) image Win7: Systems Locale: image

Upcoming version will check now the code-page(CP) of parent process's attached console and uses this CP as its ANSI default encoding (systems locale CP, if there is no parent process or the parent process has no console attached).

Feel free to test dev beta ver _5.19.1104.2666_BETA (beta channel access see: #1129)

blackcrack commented 4 years ago

@RaiKoHoff -> beep wrong s

nope, i want "chcp 850" in this and not the Windows encoded, IF IM WRITE IN THE SCRIPT : "chcp 850" want i this encoding like i have write it in the script and not "go to the N3 config encoding and do" bahh, nope, i want per "chcp 850" this encoding in the actual edited script/textfile ! If i am write a batch, then should it be also this encoding in the batch like i have writing in, not like it be in the configuring of the N3 config, i order the system/N3 this to take, you see ? verstehst Du ? :smiley:

also wenn das in script steht "chcp %codepage% sollte das script auch in dieser codepage angezeigt werden, damit das dann auch richtig ausgeführt wird.

Könntest Du das bitte einbauen ? bei öffnung des files, wenn es eine text/batch datei ist und es steht "chcp %codepage% " drin, daß die datei dann auch so gelesen wird und abgespeichert wird.

das ist nötig, daß es dann auch international möglich ist, "chcp 1370" eine batch zu schreiben oder auch in "chcp 20003" sobald das wort "chcp" auftaucht sollte die zahl dahinter als standart Codepage für das document benutzt werden. Das ist wirklich wichtig zu haben... und wenn man dann eine textdatei öffnet und darin dann chcp 850 (auch am ende des files, ganz unten, zum beispiel rein schreibt, sollte N3 das mitbekommen und das Textfile auch als 850 codieren und beim nächsten abspeichern so speichern, das selbe in Chinesisch, koreanisch, was weis ich, russisch und 874 Thai. Das ist auch international wichtig..

bei c und c++ und so gibt es ja auch eine codepageanweisung oder anweisungen, das sollte.. oder könnte man ja auch als regel einbauen, sobald " codepage 850" drinsteht .. oder mehrere codepage, das es dann bei c, zum beispiel es möglich ist mittels #;//codepage %codepage% zu schreiben und das dann als standard file encoding genommen ist..

aber ich bin hier jetzt bei Text/batch von daher, der batchbefehl chcp %codepagezahl%

könntest Du das bitte mit einbauen ? :)

best regards und viele liebe Grüße Blacky

RaiKoHoff commented 4 years ago

Okay, what you mean is called "encoding file tags". You have to enable the "Parse encoding file tag" option and put somewhere in your script (first/last 512 bytes) a comment, which has a file-tag like "REM ... encoding: CP-850 ...". Allowed strings can be found in EncodingDetection.cpp line 236 and following ...

image

blackcrack commented 4 years ago

Hi @RaiKoHoff :)

hmm, then, could you add by side of the "encoding: CP-850" also "chcp 850" add to auto encoding so encoding: CP-850 = chcp 850 or something, to add a rule to the Parse encoding if exist the command "chcp" in the script use the number behind to encode the whole file in this Encoding too ?

In this way in a Batch/cmd-script maybe better as setting up extra the "non standard" string "encoding: CP-850", chcp in the case of batchscript is more standard and can found also in the Net and in the Wiki and it is more well known to setting up the code page in a script .

best regards Blacky

RaiKoHoff commented 4 years ago

It is no good idea to base the encoding file tag on a command ("chcp 850") of any programming language. There is no "standard" for encoding file tags, but common and widely spread convention. So the parsed encoding file tag "[charset|coding|encoding] := <code-page-id>" is a kind of "defacto-standard". Some standard has been established for XML (encoding="utf-8") and the parser understands this flavor too. I don't think it is a good idea to extent the parser, so I have to reject your request - sorry. You have to live with "REM encoding: CP-850" or ":: coding="cp850"" or "charset=ibm850".