projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Display libfirm revision on --version
[cparser]
/
string_rep.h
diff --git
a/string_rep.h
b/string_rep.h
index
e24b40c
..
f3a1e6b
100644
(file)
--- a/
string_rep.h
+++ b/
string_rep.h
@@
-20,18
+20,25
@@
#ifndef STRING_REP_H
#define STRING_REP_H
#ifndef STRING_REP_H
#define STRING_REP_H
-#include <wchar.h>
-
-typedef wchar_t wchar_rep_t;
+#include <stdlib.h>
+#include "unicode.h"
typedef struct string_t {
typedef struct string_t {
- const char *begin;
- size_t size;
+ const char *begin; /**< UTF-8 encoded string, the last character is
+ * guaranteed to be 0 */
+ size_t size; /**< size of string in bytes (not characters) */
} string_t;
} string_t;
-typedef struct wide_string_t {
- const wchar_rep_t *begin;
- size_t size;
-} wide_string_t;
+static inline size_t wstrlen(const string_t *string)
+{
+ size_t result = 0;
+ const char *p = string->begin;
+ const char *end = p + string->size;
+ while (p < end) {
+ read_utf8_char(&p);
+ ++result;
+ }
+ return result;
+}
#endif
#endif