Summary: Macro to uppercase first letter of string
                 Project: Freeciv
            Submitted by: cazfi
            Submitted on: Mon 07 Nov 2011 02:08:41 AM EET
                Category: general
                Priority: 5 - Normal
                  Status: Ready For Test
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 2.4.0, 2.5.0



We sometimes want to have same translation to appear with lowercase first
letter in some places, and uppercase first letter in other places. patch #3027
may eventually lead to good solution for this, but here's quick hack for
urgent short-term (2.4, 2.3?) needs.

It introduces new macro C_() that returns string with first character
uppercased *in some cases*. It works only if that said first character is
7-bit ascii character (single-byte UTF-8 character) This is not completely
useless, as translators still control what word they push there. If all unit
names in their translation start with ascii-character, they can put them via
"%s" to the beginning of this kind of string. If some unit name does not begin
with ascii-character, they cannot put it to the beginning, but neither were
they able to do so before.

Note that unlike other xx_() macros, this does not return same statically
allocated constant string for all identical calls, but returned string is
constructed for each call. For this reason it has to be also freed with
separate function call when string is no longer needed.

Uppercasing any other characters than first one in UTF-8 text would be hard,
even if that particular character itself is ascii one. Since characters before
it are variable width, it's not easy to tell which bytes belong to which
character (or even if certain byte looking like ascii character is indeed
ascii character or latter part of multibyte character)


File Attachments:

Date: Mon 07 Nov 2011 02:08:41 AM EET  Name: C_macro.diff  Size: 3kB   By:



Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to