I suspect you didn't write your text as UTF8 to begin with.
-------------------------------------------------------------------------------------------
set htmlFilePath to ((path to downloads folder as text) & "test.file.ccs.html")
set rawHTML to "<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"utf-8\" />
<title></title>
</head>
<body>
H3R3
</body>
</html>
"
tell application "Safari"
activate
make new document with properties {URL:theURL}
delay 4
tell front document to set safariPageTitle to its name
end tell
set AppleScript's text item delimiters to "H3R3"
set rawHTML to text items of rawHTML
set AppleScript's text item delimiters to safariPageTitle
set rawHTML to rawHTML as text
writeUTF8(rawHTML, htmlFilePath)
tell application "Safari"
activate
open file htmlFilePath
end tell
-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on writeUTF8(_text, _file)
try
if _file starts with "~/" then
set _file to POSIX path of (path to home folder as text) & text 3 thru -1 of _file
end if
set fRef to open for access _file with write permission
set eof of fRef to 0
write _text to fRef as «class utf8»
close access fRef
on error e number n
try
close access fRef
on error e number n
error "Error in writeUTF8() handler!" & return & return & e
end try
end try
end writeUTF8
-------------------------------------------------------------------------------------------