This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cpplib utf8, status?


I added all this to the wiki for future reference:

http://gcc.gnu.org/wiki/FAQ#utf8_identifiers

Feel free to improve it.

Cheers,

Manuel.

On 26 April 2010 17:12, Janek Kozicki <janek_listy@wp.pl> wrote:
> Joseph S. Myers said: Â Â (by the date of Mon, 26 Apr 2010 14:15:06 +0000 (UTC))
>
>> > I suppose that "raw/real" UTF-8 will not work ;)
>> > So how do I express UCN in the code?
>>
>> By using the \uNNNN or \UNNNNNNNN syntax. ÂFor example, pipe your code
>> through
>>
>> perl -pe 'BEGIN { binmode STDIN, ":utf8"; } s/(.)/ord($1) < 128 ? $1 : sprintf("\\U%08x", ord($1))/ge;'
>
>
> Wow! It works. Thanks a lot! Unbelievable!
>
> //file UCN_almost_UTF8_identifiers.cpp
>
> #include<iostream>
> int main()
> {
> Â Â Â Âdouble Î_çåvelocity(0);
> Â Â Â Âstd::cout << "Î_vçåelocity= " << Î_çåvelocity << "\n";
> }
>
> // with following makefile:
>
> UCN_almost_UTF8_identifiers:UCN_almost_UTF8_identifiers.cpp
> Â Â Â Â/home/janek/bin/to_UCN.sh UCN_almost_UTF8_identifiers.cpp
> Â Â Â Âg++ -fextended-identifiers -o UCN_almost_UTF8_identifiers /tmp/UCN_almost_UTF8_identifiers.cpp
>
> //and the helper script: to_UCN.sh:
>
> #!/bin/bash
> cat $1 | perl -pe 'BEGIN { binmode STDIN, ":utf8"; } s/(.)/ord($1) < 128 ? $1 : sprintf("\\U%08x", ord($1))/ge;' > /tmp/$1
>
>
> I'm happy that now, for quick testing purposes, I can use UTF8 symbols
> for variable names in ÂC++, even though the code is totally not
> portable, it will work locally, and will help me a lot in writing
> physical stuff.
>
> --
> Janek Kozicki                http://janek.kozicki.pl/ Â|
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]