lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Monday, January 12, 2015 06:21:18 PM Johnson Lin wrote:
> GB and Big5 are both obsolete. And all workarounds have their limits. For
> Big5's 許功蓋 issue, usually the lowest cost way of fixing it is somehow add
> in an additional escape ('\') where the mangled character resides. But then
> you wouldn't be able to store the string in a human readable form; or,
> encapsulate all related string usages with a function call that parses the
> raw byte data, and then seek to where the additional escape are needed and
> put it in.

My suggestion would be to move the Big5 strings out of the source code and 
into a file that is read when the program starts. A gettext library will do 
this though it may be overkill. A simple list of keys and strings that is 
parsed into a table will do.

    for line in msgfile:lines() do
      local key, str = line:match "(%w[%w%d_-]*):(.*)"
      MESSAGES[key] = str
    end

-- 
tom <telliamed@whoopdedo.org>