Why do you not run a simple Replace in Files
searching for ï»¿
(Windows-1252 encoded UTF-8 BOM) and using an empty replace string?
Or when the Replace in Files
should be independent on encoding, run a Perl regular expression Replace in Files
with the search string \A\xEF\xBB\xBF
and an empty replace string.
However, if you want to really make it that complicated, look on this script code:
- Code: Select all
// string which is an array of Unicode characters.
var sBytes = UltraEdit.activeDocument.selection;
var sByteChars = "Selected: ";
var sByteCodes = " =";
// Process the string character by character
// which means in this case byte by byte.
for (var nCharIndex = 0; nCharIndex < sBytes.length; nCharIndex++)
// Get the code value of the character which means
// the integer value of the selected byte in file.
var nByteCode = sBytes.charCodeAt(nCharIndex);
// Convert this code value back to a character assigned to a
// string of length 1 and append this one character string to
// sByteChars representing the characters as bytes. Well, the
// string build here character by character is the same as sBytes.
sByteChars += String.fromCharCode(nByteCode);
// Convert the integer value of the byte to a string using hexadecimal
// system and convert the resulting string to upper case. And if the
// byte has a value smaller than 16, inserting a leading zero to have
// all bytes represented with two hexadecimal digits.
var sHexCharCode = nByteCode.toString(16).toUpperCase();
if (sHexCharCode.length < 2) sHexCharCode = '0' + sHexCharCode;
sByteCodes += ' ' + sHexCharCode;
// Build an additional information for output depending on the
// selected bytes representing a UTF-8 byte order mark or not.
var sInfo = "\n\nThis is ";
sInfo += (sBytes == String.fromCharCode(239,187,191)) ? "the UTF-8 BOM." : "anything else.";
// Output the selected bytes as string and in hexadecimal representation.
UltraEdit.messageBox(sByteChars + sByteCodes + sInfo);