xmltools
xmltools copied to clipboard
[Feature Request] detect correct file encoding for new XML files based on "encoding" header
My use case is: I have a complete block of xml and paste it to Notepad++ and save the file. The XML declares an encoding:
<?xml version="1.0" encoding="windows-1252"?>
When saving this file, Notepad++ uses default "UTF-8". So I would expect that the encoding in the menu bar changes to the detected encoding from the XML file as soon as Notepad++ detects XML content with encoding. Maybe this could be achieved if I switch to file type "XML" before saving? Or after selecting the target file with extension "XML"?
I first reported this in the Notepad++ github repository https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9372 but I think XMLTools is be a better place for handling this.
I'm afraid that NPP does not make it possible. NPP offers the message NPPM_SETBUFFERENCODING which allows to change actual encoding. Unfortunately this message is limited to UniMode type, which correspond to basic "Encoding" menu entries:
enum UniMode {
uni8Bit=0,
uniUTF8=1,
uni16BE=2,
uni16LE=3,
uniCookie=4,
uni7Bit=5,
uni16BE_NoBOM=6,
uni16LE_NoBOM=7,
uniEnd
};
I cannot find any NPP message method which allows to set any encoding (or codepage) value.
So, how to continue this issue ;-)? Does your comment mean "not possible to optimize" (if yes, we can close this issue), or do you still think about it?