KalleOlaviNiemitalo commented on code in PR #1798:
URL: https://github.com/apache/avro/pull/1798#discussion_r935512088
##########
lang/c/src/schema.c:
##########
@@ -48,26 +51,50 @@ static void avro_schema_init(avro_schema_t schema,
avro_type_t type)
static int is_avro_id(const char *name)
{
- size_t i, len;
if (name) {
- len = strlen(name);
- if (len < 1) {
- return 0;
- }
- for (i = 0; i < len; i++) {
- if (!(isalpha(name[i])
- || name[i] == '_' || (i && isdigit(name[i])))) {
+ size_t len = strlen(name);
+ if (len < 1) {
+ return 0;
+ }
+
+ locale_t loc = newlocale(LC_ALL_MASK, "en_US.UTF-8", (locale_t) 0);
+ locale_t currentLoc = (locale_t) 0;
+ if (loc) {
+ currentLoc = uselocale(loc);
+ }
+ else {
+ setlocale(LC_ALL, "en_US.UTF-8");
+ }
+
+ size_t mbslen = mbstowcs(NULL, name, 0);
+ wchar_t wsName[mbslen + 1];
+ mbstowcs(wsName, name, mbslen + 1);
Review Comment:
That code works fine here, after this initialization:
```C
const uint8_t name[] = u8"pr\u00E9nom";
int32_t len = (sizeof name) - 1;
```
The resulting values of `c` are: 112, 114, 233, 110, 111, 109
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]