xmltools icon indicating copy to clipboard operation
xmltools copied to clipboard

[Feature Request] detect correct file encoding for new XML files based on "encoding" header

Open WolfgangHG opened this issue 4 years ago • 2 comments
trafficstars

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.

WolfgangHG avatar Jul 23 '21 19:07 WolfgangHG

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.

morbac avatar Oct 25 '21 19:10 morbac

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?

WolfgangHG avatar Nov 07 '21 12:11 WolfgangHG