utf-8 string functions in c

K

Kamus of Kadizhar

How do I set up UTF-8 string constants in C?

I'd like to set up a file with some japanese fonts, and while I know the
utf-8 representation, I have no idea how to enter the constants.

--Kamus
 
J

Jason

You might have to do this manually or with a tool. Notepad will write utf-8
I think. You then have to have a program to translate that into a constant C
array. I depends what you are trying to accomplish. ROM resource files, or
some other kind of dunamic resource?
 
K

Kamus of Kadizhar

You might have to do this manually or with a tool. Notepad will write utf-8
I think. You then have to have a program to translate that into a constant C
array. I depends what you are trying to accomplish. ROM resource files, or
some other kind of dunamic resource?

I'm trying to write a config file that has UTF-8 strings in it, and has
some hard-coded defaults.

Something along the lines of

char *array[6] {
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"abcdefghijklmnopqrstuvxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz",
"aábcÄdeéěfghiíjklmnopqrÅ™sÅ¡tuúůvxyýzž",
"AÃBCÄŒDEÉFGHIÃJKLMNOÓPQRŘSÅ TUÚVWXYÃZŽ",
"aábcÄdeéěfghiíjklmnopqrÅ™sÅ¡tuúůvxyýzžAÃBCÄŒDEÉFGHIÃJKLMNOÓPQRŘSÅ TUÚVWXYÃZ"
}

and then a file which, if it exists, would redefine array.

Is there a HOWTO somewhere that tells you how to work with UTF-8 strings
in C? I'm trying to do something very simple but it's frustrating since
I'm doing it completely blind.

Thanks,

--Kamus
 
B

Ben Pfaff

Kamus of Kadizhar said:
Is there a HOWTO somewhere that tells you how to work with UTF-8 strings
in C? I'm trying to do something very simple but it's frustrating since
I'm doing it completely blind.

When I Googled for "UTF-8 FAQ" I found some useful resources.
Try it yourself.
 
D

Dan Pop

In said:
How do I set up UTF-8 string constants in C?

I'd like to set up a file with some japanese fonts, and while I know the
utf-8 representation, I have no idea how to enter the constants.

If you know the UTF-8 representation, just insert the corresponding
characters inside an ordinary string literal. Be sure to pass this
string literal only to functions expecting multibyte character strings.

If your compiler supports C99's UCNs, you can also use the \Unnnn and
\Unnnnnnnn syntax for specifying the characters by code, rather than by
UTF-8 representation.

Dan
 
K

Kamus of Kadizhar

Kamus of Kadizhar <[email protected]> writes:
When I Googled for "UTF-8 FAQ" I found some useful resources.
Try it yourself.

Alas, the vast majority of those resources have to do with enabling UTF-8
support in specific apps, terms, or Perl, or Python. I have yet to find
any documentation on functions like g_utf8_next_char, or g_utf8_strlen,
which I'm guessing are part of some library (gtk???). Googling on those
brings up gobs of code snippets, but no docs.

I guess what I'm looking for is a newbie's intro to UTF-8 - a basic
programmer's primer.

--Kamus
 
B

Ben Pfaff

Kamus of Kadizhar said:
Alas, the vast majority of those resources have to do with enabling UTF-8
support in specific apps, terms, or Perl, or Python. I have yet to find
any documentation on functions like g_utf8_next_char, or g_utf8_strlen,
which I'm guessing are part of some library (gtk???). Googling on those
brings up gobs of code snippets, but no docs.

Those functions certainly aren't part of standard C. I also
suspect they are part of gtk or glib.

I have found the FAQ at www.cl.cam.ac.uk/~mgk25/unicode.html
useful myself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,355
Latest member
MavoraTech

Latest Threads

Top