Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ General Chat _ Can Utf8 Homgraphs Simplify Special Character Use In Code?

Posted by: Jaiket Mar 25 2019, 02:12 AM

Hi,
I was wondering if it would be possible to assign Unicode homographs (they look exactly the same but are interpreted differently) to dissociate special characters according to context.

Example - the apostrophe. In strings it should always be interpreted as a human language indicator - In this sentance it's representing the letter 'i' which is missing, and it is also being used as a single quote around the letter 'i'.
In SQL, the apostrophe is used to mark the start and end of a string -

CODE
DCount("Item", "tblItem", "Item = '" & strSQL & "'") <> 0


I'm way out of my depth, but I thought that maybe if one of the contexts (probably coding) interpreted a typed apostrophe as something other than "U+0027" using a spare unicode point as a homograph it may be possible to resolve the complexities of escaping characters in code.

It could just make things worse if it ends up empowering attackers, but I am ill equipped to see if this is true.

Posted by: June7 Mar 25 2019, 02:58 AM

If I expect apostrophes in data then I use Replace() function to double the apostrophe in order to escape it.

DCount("Item", "tblItem", "Item = '" & Replace(strSQL, "'", "''") & "'") <> 0

Posted by: GroverParkGeorge Mar 25 2019, 08:33 AM

Sometimes it's best to go with the flow. One of my favorite analogies is paddling a canoe on a river. Going upstream is harder and slower. Going downstream is easier and can be faster. Why implement a rather unusual solution when a rather standard one accomplishes the same goal?

Posted by: Jaiket Mar 25 2019, 12:04 PM

I thought that if it worked it might be possible for Unicode to do a global fix so coders no longer had to escape special characters. Basically there are 2 distinct entities which are rolled into one, and in the context of code this requires everone to use the standard solution (thanks June). If it was possible to do a global fix, no-one would need a solution because the problem would no longer exist.

But it's a bit beyond me...
Thanks for setting me straight, GPG