473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

utf-8 string functions in c

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
Nov 14 '05 #1
6 8822
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?
Nov 14 '05 #2
On Tue, 10 Feb 2004 15:29:10 +0000, Jason wrote:
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",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvx yz",
"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
Nov 14 '05 #3
Kamus of Kadizhar <ya*@NsOeSiPnAeMr.com> writes:
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.
Nov 14 '05 #4
In <pa****************************@NsOeSiPnAeMr.com > Kamus of Kadizhar <ya*@NsOeSiPnAeMr.com> writes:
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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5
On Tue, 10 Feb 2004 10:20:05 -0800, Ben Pfaff wrote:
Kamus of Kadizhar <ya*@NsOeSiPnAeMr.com> 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
Nov 14 '05 #6
Kamus of Kadizhar <ya*@NsOeSiPnAeMr.com> writes:
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.
--
"In My Egotistical Opinion, most people's C programs should be indented six
feet downward and covered with dirt." -- Blair P. Houghton
Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: EU citizen | last post by:
Do web pages have to be created in unicode in order to use UTF-8 encoding? If so, can anyone name a free application which I can use under Windows 98 to create web pages?
38
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I...
1
by: stevelooking41 | last post by:
Can someone explain why I don't seem unable to use document.write to produce a valid UTF-8 none breaking space sequence (Hex: C2A0) ? I've tried everyway I've been able to find to tell the...
1
by: JJBW | last post by:
Hi I am creating some aspx files in Visual Studio 2003 for a Danish web site. The page is encoded as UTF-8 - However, when I save the the aspx file as "UTF-8 without signature" the Danish...
3
by: Richard Connamacher | last post by:
I'm new to PostgreSQL, and from the looks of it, it's a great database, and I'll be using more of it in the future. I had a quick question if anyone could clear this up. The documentation for...
23
by: Steven T. Hatton | last post by:
This is one of the first obstacles I encountered when getting started with C++. I found that everybody had their own idea of what a string is. There was std::string, QString, xercesc::XMLString,...
1
by: David Bertoni | last post by:
Hi all, I'm trying to resolve what appears to me an inconsistency in the XML 1.0 recommendation involving entities encoding in UTF-16 and the requirement for a byte order mark. Section 4.3.3...
6
by: archana | last post by:
Hi all, can someone tell me difference between unicode and utf 8 or utf 18 and which one is supporting more character set. whic i should use to support character ucs-2. I want to use ucs-2...
10
by: Jed | last post by:
I have a form that needs to handle international characters withing the UTF-8 character set. I have tried all the recommended strategies for getting utf-8 characters from form input to email...
35
by: Bjoern Hoehrmann | last post by:
Hi, For a free software project, I had to write a routine that, given a Unicode scalar value U+0000 - U+10FFFF, returns an integer that holds the UTF-8 encoded form of it, for example, U+00F6...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.