util-src/encodings.cpp

changeset 3764
323169f229fa
parent 3762
f02bac902a1e
equal deleted inserted replaced
3763:1ae89ac7bf62 3764:323169f229fa
120 }; 120 };
121 121
122 /***************** STRINGPREP *****************/ 122 /***************** STRINGPREP *****************/
123 #ifndef USE_STRINGPREP_ICU 123 #ifndef USE_STRINGPREP_ICU
124 /****************** libidn ********************/ 124 /****************** libidn ********************/
125 extern "C" {
125 #include <stringprep.h> 126 #include <stringprep.h>
126 127 }
127 static int stringprep_prep(lua_State *L, const Stringprep_profile *profile) 128 static int stringprep_prep(lua_State *L, const Stringprep_profile *profile)
128 { 129 {
129 size_t len; 130 size_t len;
130 const char *s; 131 const char *s;
131 char string[1024]; 132 char string[1024];
138 if (len >= 1024) { 139 if (len >= 1024) {
139 lua_pushnil(L); 140 lua_pushnil(L);
140 return 1; // TODO return error message 141 return 1; // TODO return error message
141 } 142 }
142 strcpy(string, s); 143 strcpy(string, s);
143 ret = stringprep(string, 1024, 0, profile); 144 ret = stringprep(string, 1024, (Stringprep_profile_flags)0, profile);
144 if (ret == STRINGPREP_OK) { 145 if (ret == STRINGPREP_OK) {
145 lua_pushstring(L, string); 146 lua_pushstring(L, string);
146 return 1; 147 return 1;
147 } else { 148 } else {
148 lua_pushnil(L); 149 lua_pushnil(L);
167 { NULL, NULL } 168 { NULL, NULL }
168 }; 169 };
169 170
170 #else 171 #else
171 #include <unicode/usprep.h> 172 #include <unicode/usprep.h>
172 //#include <unicode/stringpiece.h>
173 #include <unicode/unistr.h> 173 #include <unicode/unistr.h>
174 #include <unicode/utrace.h> 174 #include <unicode/utrace.h>
175 175
176 static int icu_stringprep_prep(lua_State *L, const UStringPrepProfile *profile) 176 static int icu_stringprep_prep(lua_State *L, const UStringPrepProfile *profile)
177 { 177 {

mercurial