Page 1 of 1

Transform's HTML subcommand: char 8218

Posted: 16 Oct 2017, 13:48
by jeeswg
I've been getting strange results when trying to convert characters to their HTML equivalents. Specifically with Chr(8218), which should be sbquo.

Since this functionality is due to be removed in AHK v2, I'm trying to create a custom function to emulate it.

Code: Select all

;trigger this hotkey a few times to see different results for Chr(8218)
q:: ;test Transform's HTML subcommand
vOutput := ""
Loop, 10
{
	vIndex := 8215+A_Index+2 ;change +2 as required
	vText := Chr(vIndex)
	Transform, vHtml, HTML, % vText
	if !(vText = vHtml)
		vOutput .= vIndex "`t" vHtml "`r`n"
}
Clipboard := vOutput
MsgBox, % vOutput
return

Code: Select all

==============================
[start at 8216]
8216	‘
8217	’
8218	&ssquo; ;INCORRECT
8220	“
8221	”
8222	„
8224	†
8225	‡
==============================
[start at 8217]
8217	’
8218	&ssquo; ;INCORRECT
8220	“
8221	”
8222	„
8224	†
8225	‡
8226	•
==============================
[start at 8218]
8218	&s017 ;INCORRECT

8220	“
8221	”
8222	„
8224	†
8225	‡
8226	•
==============================
[start at 8219]
8220	“
8221	”
8222	„
8224	†
8225	‡
8226	•
==============================

Re: Transform's HTML subcommand: char 8218

Posted: 16 Oct 2017, 14:23
by TheDewd
Specifying a flag for the Transform command seems to help:
Transform, vHtml, HTML, % vText, 3

Code: Select all

8218	‚
8219	‛
8220	“
8221	”
8222	„
8223	‟
8224	†
8225	‡
8226	•
8227	‣