string.c
changeset 5380 8ea58542b6e0
parent 5165 028df092bebd
equal deleted inserted replaced
5379:929378a0014f 5380:8ea58542b6e0
   206 			*c = GB(s[0], 0, 3) << 18 | GB(s[1], 0, 6) << 12 | GB(s[2], 0, 6) << 6 | GB(s[3], 0, 6);
   206 			*c = GB(s[0], 0, 3) << 18 | GB(s[1], 0, 6) << 12 | GB(s[2], 0, 6) << 6 | GB(s[3], 0, 6);
   207 			if (*c >= 0x10000 && *c <= 0x10FFFF) return 4;
   207 			if (*c >= 0x10000 && *c <= 0x10FFFF) return 4;
   208 		}
   208 		}
   209 	}
   209 	}
   210 
   210 
   211 	//DEBUG(misc, 1) ("Invalid UTF-8 sequence");
   211 	//DEBUG(misc, 1, "[utf8] invalid UTF-8 sequence");
   212 	*c = '?';
   212 	*c = '?';
   213 	return 1;
   213 	return 1;
   214 }
   214 }
   215 
   215 
   216 
   216 
   239 		*buf++ = 0x80 + GB(c,  6, 6);
   239 		*buf++ = 0x80 + GB(c,  6, 6);
   240 		*buf   = 0x80 + GB(c,  0, 6);
   240 		*buf   = 0x80 + GB(c,  0, 6);
   241 		return 4;
   241 		return 4;
   242 	}
   242 	}
   243 
   243 
   244 	//DEBUG(misc, 1) ("Can't UTF-8 encode value 0x%X", c);
   244 	//DEBUG(misc, 1, "[utf8] can't UTF-8 encode value 0x%X", c);
   245 	*buf = '?';
   245 	*buf = '?';
   246 	return 1;
   246 	return 1;
   247 }
   247 }