love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
5.08k stars 401 forks source link

Support for UTF-8 #19

Closed slime73 closed 13 years ago

slime73 commented 14 years ago

Original report by Linus (Bitbucket: thelinx, GitHub: thelinx).


slime73 commented 14 years ago

Original comment by Bill Meltsner (Bitbucket: bmelts, GitHub: bmelts).


20 was marked as a duplicate of this issue.

slime73 commented 14 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Does anybody know of a way to make lua handle utf-8 gracefully?

slime73 commented 14 years ago

Original comment by Anonymous.


I'd like to know more about this issue. What exactly is that Lua doesn't "gracefully" do about utf-8? Do you have samples / links?

slime73 commented 14 years ago

Original comment by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


One way would be to have a String type that can be converted from and to Lua strings, which does handle UTF-8/Unicode without all the problems. It doesn't seem to be the most elegant solution, but if there is no better one...

slime73 commented 14 years ago

Original comment by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


Whoops

slime73 commented 14 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Yeah, I'm kind of afraid of that, we do want to have standard lua..

slime73 commented 14 years ago

Original comment by Дмитрий Ларченко (Bitbucket: neokril, GitHub: neokril).


//Yeah, I'm kind of afraid of that, we do want to have standard lua..//

Maybe use some separate resource files with localized (UTF) strings. In code we can use ASCII ID's of that strings...

Example:

love.graphics.print( love.gettext("Hello") )
slime73 commented 14 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


That might be a good idea, thanks!

slime73 commented 14 years ago

Original comment by Robin Wellner (Bitbucket: gvx, GitHub: gvx).


We could call that function u (or have it as an alias), so one could use the pythonesk u"Hello" (or something else short and unobtrusive)

slime73 commented 14 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Good that you mentioned it, and please stop changing the status....

slime73 commented 14 years ago

Original comment by Linus (Bitbucket: thelinx, GitHub: thelinx).


I think we should just make a love.gettext module with appropriate function, and if you want to use u "Hello", then you can just localize love.gettext.getString (or whatever it will be called) function.

slime73 commented 14 years ago

Original comment by Anonymous.


Bump!

slime73 commented 14 years ago

Original comment by Anonymous.


Bump!

slime73 commented 14 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


What is this? Anonymous people: stop bumping!

slime73 commented 14 years ago

Original comment by Linus (Bitbucket: thelinx, GitHub: thelinx).


Bump!

slime73 commented 14 years ago

Original comment by Eduard Matsukov (Bitbucket: [Eduard Matsukov](https://bitbucket.org/Eduard Matsukov), ).


Would be nice to use something like iconv library. Added the soruce for lua 5.1.4 It works via code:

#!lua
require 'iconv/init'

print(('Кириллица - cyrillic text'):convert('cp1251','utf-8'))

Supported encodes: ASCII, ISO-8859-{1,2,3,4,5,7,9,10,13,14,15,16}, KOI8-R, KOI8-U, KOI8-RU, CP{1250,1251,1252,1253,1254,1257}, CP{850,866}, CP{437,737,775,852,853,855,857,858,860,861,863,865,869,1125}, Mac{Roman,CentralEurope,Iceland,Croatian,Romania}, Mac{Cyrillic,Ukraine,Greek,Turkish}, Macintosh UTF-8, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, UTF-7, UCS-2, UCS-2BE, UCS-2LE, UCS-4, UCS-4BE, UCS-4LE, C99, JAVA, UCS-2-INTERNAL, UCS-4-INTERNAL ISO-8859-{6,8}, CP{1255,1256}, CP862, CP864, Mac{Hebrew,Arabic} HP-ROMAN8, NEXTSTEP ARMSCII-8 VISCII, TCVN, CP1258 Georgian-Academy, Georgian-PS EUC-CN, HZ, GBK, GB18030, EUC-TW, BIG5, CP950, BIG5-HKSCS, ISO-2022-CN, ISO-2022-CN-EXT EUC-KR, CP949, ISO-2022-KR, JOHAB MuleLao-1, CP1133 KOI8-T TIS-620, CP874, MacThai EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-1, ISO-2022-JP-2

Hope it may be usefull.

slime73 commented 14 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Well, so far the biggest problem isn't getting lua to recognize it, the biggest problem is finding a good way to output it.

slime73 commented 14 years ago

Original comment by Eduard Matsukov (Bitbucket: [Eduard Matsukov](https://bitbucket.org/Eduard Matsukov), ).


There is good xml-parser (wxXmlDocument) in wxLua (wxWidgets binded to native Lua) with decoding local user file on loading - it could be usefull, i hope.

slime73 commented 14 years ago

Original comment by Meng Jie (Bitbucket: inmouse, ).


I have a experimental implementation of output utf-8 string in love. It is avaliable in my fork.

In the implementation, string is just simply treat as a utf-8 string, because utf-8 is compatible with the ANSI(0-127), so in most time it works fine.

please kindly check it. thanks.

slime73 commented 13 years ago

Original comment by m (Bitbucket: m, GitHub: m).


I just got that to compile (if my experience is typical, anyone who can compile the main branch should be able to handle the modified version). What kind of tests should I be running on it? I got Hello World with gratuitous unicode added to work properly, but I assume that stuff like framerate and memory consumption are potential concerns. (Just, generically. Imagine I am utterly unqualified to make any statements about this, because I am.)

I'm running Snow Leopard on a new MacBook Pro, and there's an outside chance I can bash out binaries for other platforms if anyone else is curious, but has even more trouble compiling than I did. (I make no guarantees about stuff like... compatibility with anything other than my specific architectures, because I'm completely new at anything more advanced than compile-make-make.)

slime73 commented 13 years ago

Original comment by Bill Meltsner (Bitbucket: bmelts, GitHub: bmelts).


This is implemented as of <<changeset 542>>. Finally.

slime73 commented 13 years ago

Original comment by Anonymous.


Two questions about "This is implemented as of r542:4ca613c9690e . Finally."

  1. Can someone please explain to the newbie how to use it?

  2. Does 0.7.1 version(for Windows) includes this? And if not then when?

Best regards, Anonymous Lover.

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


Dear Anonymous Lover

UTF8 will be included in LÖVE 0.8.0.\ You can already use it by building the minor branch of this repository yourself, but it's in a early stage right now and probably has some bugs.

Once you have a running executable you can pass UTF8 strings to love.graphics.print().

slime73 commented 13 years ago

Original comment by Bill Meltsner (Bitbucket: bmelts, GitHub: bmelts).


286 was marked as a duplicate of this issue.