User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Help with writing and playing macros
3 posts Page 1 of 1
I use a US keyboard (or occasionally certain variants similar to Dvorak), and was poking around with trying to add macros to apply diacriticals to text. Since unicode has combining diacriticals (ie: standalone diacriticals which will combine with the preceding character to form the final character; eg: a + ̀ = à), I wanted a set of macros that I could use to just insert the standalone combining diacritical after a character in order to modify that character (rather than needing to add the final form of every character variant in its own macro).

However, I can't seem to enter the unicode character within the macro edit window. For example, the grave accent is Alt+0768 (using the decimal codepoint). However since it's not a printable character in and of itself, it seems that the macro window won't allow it to be entered as something to be output to the file.

Is there a way to do what I'm trying to do here?
So instead of pressing ` and next a to get letter a-grave with decimal Unicode value 224 (U+00E0) into the file encoded in UTF-8 with C3 A0 as I do on a German keyboard, you press letter key a for inserting this character with decimal Unicode value 97 (U+0061) and next press Alt+0768 (on numeric keyboard) to insert additionally the combining grave accent with decimal Unicode value 768 (U+0300) stored together in a UTF-8 encoded file as 61 CC 80.

Macros are stored binary with 1 byte per character for strings with the exception of find/replace strings which are stored UTF-8 encoded in the macro file. The Edit/Create Macro dialog supports only ASCII/ANSI editing which is also the reason why non ASCII characters - characters with a decimal value > 127) - in a recorded find/replace string are displayed in the dialog with their UTF-8 byte sequences.

I quick recorded a key press of a and Alt+0768 into a macro, stopped quick recording, and played this macro again. But the macro replay did not result in getting displayed an a-grave because of an a with a combining grave accent. So this approach does not work. Of course editing the macro to insert just the combining grave accent does not work, too.

But it is nevertheless possible to create a macro which inserts into the file a combining grave accent. Here is the code:

Code: Select all
InsertMode
" "
Key LEFT ARROW
PerlReOn
Find RegExp " "
Replace "\x{0300}"

This little code inserts a space character. Next it moves character back to initial position left to just inserted space character. Then it runs a single Perl regular expression to replace the space character by a combining grave accent.

This macro executed after inserting for example letter a results in getting displayed à with using a fully Unicode aware font like Arial Unicode MS encoded in UTF-16 LE with 61 00 00 03 (4 bytes) and in UTF-8 with 61 CC 80 (3 bytes). With other fonts like Courier New the display is a` as not supporting combined characters while à inserted with pressing ` and next a on German keyboard encoded in UTF-16 LE with E0 00 (2 bytes) and in UTF-8 with C3 A0 (2 bytes) is displayed as à also with Courier New.
Best regards from Austria
Thanks for the solution. There are still a few finicky bits I'll need to look into (such as removing the diacritic on a second application, instead of creating a large stack of values), but it's enough for basic use.
3 posts Page 1 of 1