Hello script writers!
As discussed at Selection only returns first character there is currently (see post date) a problem with Unicode files.
The workaround posted by in0de using
does not work on Windows 98. Don't know why. However, it is not a fine solution.
Here is a much better one. A function which detects if UltraEdit or UEStudio has loaded a file as Unicode or not. By using this function after opening a file it is possible to convert to ASCII only if required because the file is really a Unicode file.
If you want to report mistakes or have suggestions for further enhancements post a message here.
The script file IsUnicode.js with the code can be viewed or downloaded from the Macros & Scripts page.
The line and block comments can be removed from entire script or function IsUnicode by running a replace all (from top of file) searching with Perl regular expression for ^ *//.+[\r\n]+|^ */\*[\s\S]+?\*/[\r\n]+| +//.+$ and using an empty replace string. The first part in this OR expression with three arguments matches entire lines containing only a line comment, the second part matches block comments, and third part matches line comments right to code. Removal of the comments makes the usage of this script or just the function in other scripts more efficient because of JavaScript interpreter has to interpret less characters and lines.
Many comments were improved on 2018-07-09 as well as a message displayed either with a message box or written to output window..
As discussed at Selection only returns first character there is currently (see post date) a problem with Unicode files.
The workaround posted by in0de using
Code: Select all
UltraEdit.activeDocument.ASCIIToUnicode();
UltraEdit.activeDocument.unicodeToASCII();
Here is a much better one. A function which detects if UltraEdit or UEStudio has loaded a file as Unicode or not. By using this function after opening a file it is possible to convert to ASCII only if required because the file is really a Unicode file.
Code: Select all
if (IsUnicode()) UltraEdit.activeDocument.unicodeToASCII();
The script file IsUnicode.js with the code can be viewed or downloaded from the Macros & Scripts page.
The line and block comments can be removed from entire script or function IsUnicode by running a replace all (from top of file) searching with Perl regular expression for ^ *//.+[\r\n]+|^ */\*[\s\S]+?\*/[\r\n]+| +//.+$ and using an empty replace string. The first part in this OR expression with three arguments matches entire lines containing only a line comment, the second part matches block comments, and third part matches line comments right to code. Removal of the comments makes the usage of this script or just the function in other scripts more efficient because of JavaScript interpreter has to interpret less characters and lines.
Many comments were improved on 2018-07-09 as well as a message displayed either with a message box or written to output window..