Jump to content

Recommended Posts

Posted

Hello everyone

I'm using _ClipPutHTML in a script that reads clipboard data from a text file and puts it in the clipboard, but the non-English letters put to the clipboard end up broken.  The text file is in UTF8 with BOM, and I read it with FileOpen 128 (which is UTF8 with BOM, right)?  Then I use _ClipPutHTML to put the text on the clipboard, but when I paste that text into a formatted text editor again, characters like ê and ï end up either as unknown characters or misinterpreted characters.

Does anyone know what I should do to get _ClipPutHTML to read/write the UTF8 correctly?

Even if I adapt the sample script from https://sites.google.com/site/ascend4ntscode/clipputhtml the non-English characters get broken.  For example:

#include <_ClipPutHTML.au3>

$sHTMLStr='<html>' & @CRLF & '<body>' & @CRLF & '<!--StartFragment--><span style="color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">a b c d ê f g h ï j k</span><!--EndFragment-->' & @CRLF & '</body>' & @CRLF & '</html>'

_ClipPutHTML($sHTMLStr)

...gives me " a b c d ꠦ g h k " instead of " a b c d ê f g h ï j k " when I paste into e.g. MS Word.

How can I ensure that the characters get sent to the clipboard correctly"?

Thanks

Samuel

Posted

Oh, wait, I think I found the solution:

#include <_ClipPutHTML.au3>

$sHTMLStr='<html>' & @CRLF & '<body>' & @CRLF & '<!--StartFragment--><span style="color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">a b c d ê f g h ï j k</span><!--EndFragment-->' & @CRLF & '</body>' & @CRLF & '</html>'

$sHTMLStr=BinaryToString(StringToBinary($sHTMLStr,4),1)

_ClipPutHTML($sHTMLStr)

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...