-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example for documentation #106
Comments
Examples would be welcome, but sounds like they should go into the README or into the manual? |
Note that utf8proc does not handle printing of UTF-8 strings. To print a UTF-8 string you can just use |
The main purpose of this library is for things like Unicode normalization, case-folding, etcetera, that require Unicode data tables. There are also functions to encode/decode Unicode codepoints to/from UTF-8, as described in the manual — maybe that is what you mean by "creating" and "reading" UTF-8 strings? |
Would be perfect too.
I know but this could really help beginner to understand basic use of the library. Like you said that for example the user has to read and write string him/herself. My issue come from a question in stack overflow, this one. I have been unable to provide an answer because I didn't understand how to use this library. I try this but I'm sure that it's not the way to do it:
|
@Stargateur : First of all, your code has an important error that will make it fail no matter the libraries you use for UTF-8: You statically allocate 6 bytes for a string made of 6 bytes. That's not correct. Strings in the C language are null-terminated: They need a zero byte at the end. So, you need to allocate 7 bytes for a string that has 6 bytes of data. For static allocation, the compiler can do this automatically for you, if you leave empty the string length between brackets. Read any good chapter about strings in a good C language book, and you'll learn all of this. Second, you don't need utf8proc for declaring a UTF-8 string and printing it. In your case, your code could be reduced to something as simple as this: only two lines:
As simple as that. |
I agree a directory of examples would be great to have! |
(I was about to create a new issue, but this one seems to be a good fit.) I'm also looking for examples. What I'm trying to do is implement an iterator function that iterates over graphemes (in C). I'm implementing it as a patch to One reference that I haven't looked at yet is the Do you know of any other references, or perhaps an existing implementation? |
The link 404s. |
Bump to this. |
I didn't find any example.
This would be possible to add a folder example with all necessary example to print, iterate, create, read a UTF-8 string with this library ?
The text was updated successfully, but these errors were encountered: