Prev | Current Page 162 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

This is helpful when exchanging a delimiter in your string for a different character:
var oldStr : String = ???item1,item2,item3???;
var newStr : String = StringTools.replace(oldStr, ???,???, ???;???);
Encoding Strings for the Web
The StringTools class provides several methods for safeguarding your strings from the perils of
transferring them across the Internet. If you are transferring your strings using the GET method, you will
need to encode them correctly so that the string is sent without being modified on its journey and to help
guarantee that it makes it in one piece. You can do this in haXe using the urlEncode method:
var encodedStr : String = StringTools.urlEncode(???String to send ???);
Retrieving an encoded string on the other end of its journey can then be accomplished using the
urlDecode method:
var newStr : String = StringTools.urlDecode(receivedStr);
If you then want to display that string in a browser, some of the symbols you need to display may be
read differently as HTML symbols, so will need to be escaped.


Pages:
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174