Automate Unicode character encoding for HTML

Unicode character encoding

Our CMS does not support Unicode text thus when we need to search-replace for characters like the and © symbols. This takes a fair amount of time and is easy to miss so I wrote a script in AutoHotKey to automatically handle the Unicode character encoding.

Now I can highlight the word and click a button and  Whamo!  Instant replacement with HTML equivalents!  No more trying to scan text and find illegal characters.

Unicode character encoding

Here is the AutoHotKey code I use.  My code first grabs the highlighted text and copies it to the clipboard, where it manipulates it, then sends it back to the active program I was working in. No more need for Unicode character encoding!

 
gosub Store_Clipboard_Copy_Selected_Text
;http://ahkscript.org/docs/commands/Transform.htm  http://www.w3schools.com/charsets/ref_html_8859.asp
Transform,Clipboard,html,%Clipboard%,3  ;3=numbered expressions used where named expression not available
Clipboard:= RegExReplace(Clipboard, "mUs)&bull;\s(.*).<br>", "    <li>$1</li>") ;convert bullet & br to ul
Clipboard:= RegExReplace(Clipboard, "    <li>(.*)</li>", "  <ul>`r`n    <li>$1</li>`r`n  </ul>") ;convert bullet & br to ul
Clipboard:= RegExReplace(Clipboard, "mUs).<br>", "<br>") ;convert bullet & br to ul

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.