Software /
code /
prosody
Comparison
util-src/encodings.c @ 7998:604beb13596a
util.encodings: Make limit lookup table a const (from Lua f2a813ae)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 22 Mar 2017 23:40:53 +0100 |
parent | 7889:b8d694646597 |
child | 8291:fba1ea67f5c0 |
comparison
equal
deleted
inserted
replaced
7997:aca13c433e45 | 7998:604beb13596a |
---|---|
171 | 171 |
172 /* | 172 /* |
173 * Decode one UTF-8 sequence, returning NULL if byte sequence is invalid. | 173 * Decode one UTF-8 sequence, returning NULL if byte sequence is invalid. |
174 */ | 174 */ |
175 static const char *utf8_decode(const char *o, int *val) { | 175 static const char *utf8_decode(const char *o, int *val) { |
176 static unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF}; | 176 static const unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF}; |
177 const unsigned char *s = (const unsigned char *)o; | 177 const unsigned char *s = (const unsigned char *)o; |
178 unsigned int c = s[0]; | 178 unsigned int c = s[0]; |
179 unsigned int res = 0; /* final result */ | 179 unsigned int res = 0; /* final result */ |
180 | 180 |
181 if(c < 0x80) { /* ascii? */ | 181 if(c < 0x80) { /* ascii? */ |