[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Portability of ordering of strings
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 28 Dec 2011 08:34:32 +0200
The pseudocode for the `le` and `lt` metamethods say that Lua uses
lexicographic ordering of strings. This ordering is well-defined for
strings already internalized: compare bytes until unequal, if this
does not happen before the end of one of the strings then the shorter
one is less.
For strings in Lua source code, lexicographic ordering is obviously
locale-dependent. But how much can one rely on? Lua runs on some
non-ASCII compliant platforms (EBCDIC springs to mind), but is there
any platform supporting Lua
on which the following program prints something?
s =" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
for i=2,#s do if s:sub(i,i)<=s:sub(i-1,i-1) then print(i) end end