Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: LCS: Unicode support for Linux  (Read 2013 times)

Wisq

  • Bay Watcher
    • View Profile
LCS: Unicode support for Linux
« on: February 17, 2008, 12:31:00 am »

Okay, I think I've got it.  The newspapers are a little messed up, but it's good enough at this point that I think it can be reviewed and possibly merged (if approved).

Source code changes:

  • configure.ac now has much more ncurses-related logic.  It'll pick between ncurses and ncursesw, with priority on wide character support.
  • If wide character support is available, it defines HAVE_WIDE_NCURSES.
  • Unicode mode (CH_USE_UNICODE) is enabled if HAVE_WIDE_NCURSES and __STDC_ISO_10646__ are both defined.  The latter is provided by the C compiler, and indicates that wchar_t represents Unicode codepoints.  (If it's not set, then I have no idea how to make Unicode chars.)
  • The "ASCII hack" defines are loaded if either CH_USE_ASCII_HACK or CH_USE_UNICODE are set, but they're renamed from CH_* to CH_HACK_*.
  • If CH_USE_ASCII_HACK is set, then the CH_HACK_* defines are aliased back to CH_*.

When compiled with CH_USE_UNICODE:

  • A conversion table from Unicode codepoint defines to CH_HACK_* defines is supplied (hence the above changes).
  • At runtime, the locale is checked.  If UTF-8, then Unicode mode is enabled.
  • addch(a) is redefined to point to addch_unicode(a).  This will print out the Unicode character in question.  But . . .
  • If Unicode mode is not enabled (and the char is not 7bit-clean), addch_unicode will translate it to a hack code first.

Here's the code:
Patch format
ZIP of source files

(Per the subject, this is for Linux only.  None of this will have any effect for you Windows users.)

Logged

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: LCS: Unicode support for Linux
« Reply #1 on: February 17, 2008, 12:37:00 am »

I might be missing something, but wouldn't it be easier to commit to SVN rather than giving me the files and having me do it?   :confused:
Logged

Wisq

  • Bay Watcher
    • View Profile
Re: LCS: Unicode support for Linux
« Reply #2 on: February 17, 2008, 12:38:00 am »

Well, if you want to give me access to SVN, sure, I can do it.    :)

(SF.net account name is 'wisq'.  I've never written to an SVN repo, but it seems fairly simple, so I don't think I'll mess anything up.)

Edit: Before I commit, if you don't mind, it'd be good to get the modified files out of mixed DOS/UNIX mode.  Basically, I run dos2unix on them, then "svn propset svn:eol-style native" on them, which means that when they're checked out in Unix, they'll have Unix line endings (LF) and when they're checked out on Windows, they'll have Windows/DOS style line endings (CRLF).  Right now, some are in CRLF, some are in LF, some are mixed (!), and some actually have CRCRLF (!!).  Rather than converting them all at once, I can just start with the ones I modify and we can see how it goes?

[ February 17, 2008: Message edited by: Wisq ]

Logged

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: LCS: Unicode support for Linux
« Reply #3 on: February 17, 2008, 01:38:00 am »

Okay, added you to the project. Frankly... I have zero knowledge of what newline characters the files use. It's all invisible to me, as the editors I use are capable of intelligently understanding whatever nonsense it manages to bungle together. So go ahead and do what you want to do and we'll just revert it if it's bad. :P
Logged

Wisq

  • Bay Watcher
    • View Profile
Re: LCS: Unicode support for Linux
« Reply #4 on: February 17, 2008, 01:44:00 am »

Okay, converted some files; I'll install TortoiseSVN on my Windows box and check them out to make sure it worked right.
Logged

Wisq

  • Bay Watcher
    • View Profile
Re: LCS: Unicode support for Linux
« Reply #5 on: February 17, 2008, 02:10:00 am »

Stuff's committed.  Seems to work fine, and SVN is indeed pretty easy to use; no problems there.  I guess I'm used to distributed version control, and SVN is pretty simple by comparison.  :D

Let me know if you still want me to at least run the big stuff by you before committing.  It sounds like you're happy enough to just roll stuff back if you don't want it, though.  I generally avoid the game balance stuff and just stick to  technical stuff, so there shouldn't be much clashing, if any.

Logged

Mercutio Valentine

  • Bay Watcher
    • View Profile
Re: LCS: Unicode support for Linux
« Reply #6 on: February 17, 2008, 02:32:00 am »

...I got a good feeling. This is the way!

(Seriously, awesome fix, and awesome that y'all are actually working together now. Wisq gettin' in the game credits? :P)

Logged

Wisq

  • Bay Watcher
    • View Profile
Re: LCS: Unicode support for Linux
« Reply #7 on: February 17, 2008, 05:09:00 am »

Updated the stairs and squad symbols.  Looks pretty nifty now.

Before and after:
 

Logged

Wisq

  • Bay Watcher
    • View Profile
Re: LCS: Unicode support for Linux
« Reply #8 on: February 17, 2008, 06:16:00 am »

Fixed news!  It never looked great with the ASCII hack (and still doesn't), but my Unicode changes broke it much worse.  :D

[ February 17, 2008: Message edited by: Wisq ]

Logged

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: LCS: Unicode support for Linux
« Reply #9 on: February 17, 2008, 12:21:00 pm »

Er? What's all this "<<<<<<< .mine" in the source? Is that supposed to be there? It's all syntax errors for me.

Edit: Okay, I see how it is, the merge got butchered. I'm looking into it.

Edit 2: After many false fixes, I think I've finally got it working.  :( Let me know if you run into any problems with the latest revision.

[ February 17, 2008: Message edited by: Jonathan S. Fox ]

[ February 17, 2008: Message edited by: Jonathan S. Fox ]

Logged

Wisq

  • Bay Watcher
    • View Profile
Re: LCS: Unicode support for Linux
« Reply #10 on: February 17, 2008, 02:12:00 pm »

Yeah, those would have been conflict markers.  One of the caveats to line-ending fixing is that, while it does fix the file pretty much for all time (yay!), it involves one big change (every non-native line ending in the file!) to do it.

That means any uncommitted changes to the file by another developer will show up as a conflict on update.    :(  But thankfully, that's a one-time thing.  I didn't think it would be a problem since I didn't think you were working on the same files I was converting.

Of course, it's possible the conflicts were something else entirely, but that's my guess.

Things compile and seem to run fine now, so I guess we made it through.

Edit:  Yeah, I think that's what it was -- I'm assuming it was game.cpp and includes.h that gave you trouble, looking at the changes.

[ February 17, 2008: Message edited by: Wisq ]

Logged