/* unread the bytes beyond what was consumed for U+FEFF */
T_FileStream_rewind(in); if (*signatureLength > 0) {
T_FileStream_read(in, start, *signatureLength);
}
if(*cp==nullptr){
*conv =nullptr; returnfalse;
}
/* open the converter for the detected Unicode charset */
*conv = ucnv_open(*cp,error);
memcpy(postContext,source,stop-start); /* null terminate the buffer */
postContext[stop-start] = 0;
if(buf->showWarning ==true){ /* print out the context */
fprintf(stderr,"\tPre-context: %s\n",preContext);
fprintf(stderr,"\tContext: %s\n",context);
fprintf(stderr,"\tPost-context: %s\n", postContext);
}
/* reset the converter */
ucnv_reset(buf->conv);
/* set the call back to substitute *andrestartconversion
*/
ucnv_setToUCallBack(buf->conv,
UCNV_TO_U_CALLBACK_SUBSTITUTE,
toUNewContext,
&toUOldAction,
(constvoid**)&toUOldContext,
&error1);
/* u_unescapeAt() callback to return a char16_t*/ static char16_t U_CALLCONV
_charAt(int32_t offset, void *context) { returnstatic_cast<UCHARBUF*>(context)->currentPos[offset];
}
/* getc and escape it */
U_CAPI int32_t U_EXPORT2
ucbuf_getcx32(UCHARBUF* buf,UErrorCode* error) {
int32_t length;
int32_t offset;
UChar32 c32,c1,c2; if(error==nullptr || U_FAILURE(*error)){ returnfalse;
} /* Fill the buffer if it is empty */ if (buf->currentPos >=buf->bufLimit-2) {
ucbuf_fillucbuf(buf,error);
}
/* Get the next character in the buffer */ if (buf->currentPos < buf->bufLimit) {
c1 = *(buf->currentPos)++;
} else {
c1 = U_EOF;
}
c2 = *(buf->currentPos);
/* If it isn't a backslash, return it */ if (c1 != 0x005C) { return c1;
}
/* Determine the amount of data in the buffer */
length = (int32_t)(buf->bufLimit - buf->currentPos);
/* The longest escape sequence is \Uhhhhhhhh; make sure
we have at least that many characters */ if (length < 10) {
/* fill the buffer */
ucbuf_fillucbuf(buf,error);
length = (int32_t)(buf->bufLimit - buf->buffer);
}
/* Process the escape */
offset = 0;
c32 = u_unescapeAt(_charAt, &offset, length, (void*)buf);
/* check if u_unescapeAt unescaped and converted *toc32ornot
*/ if(c32==(UChar32)0xFFFFFFFF){ if(buf->showWarning) { char context[CONTEXT_LEN+1];
int32_t len = CONTEXT_LEN; if(length < len) {
len = length;
}
context[len]= 0 ; /* null terminate the buffer */
u_UCharsToChars( buf->currentPos, context, len);
fprintf(stderr,"Bad escape: [%c%s]...\n", (int)c1, context);
}
*error= U_ILLEGAL_ESCAPE_SEQUENCE; return c1;
}elseif(c32!=c2 || (c32==0x0075 && c2==0x0075 && c1==0x005C) /* for \u0075 c2=0x0075 and c32==0x0075*/){ /* Update the current buffer position */
buf->currentPos += offset;
}else{ /* unescaping failed so we just return *c1andnotconsumethebuffer *thisisusefulforruleswithescapes *inresourcebundles *eg:\'\\\"
*/ return c1;
}
U_CAPI const char16_t* U_EXPORT2
ucbuf_readline(UCHARBUF* buf,int32_t* len,UErrorCode* err){
char16_t* temp = buf->currentPos;
char16_t* savePos =nullptr;
char16_t c=0x0000; if(buf->isBuffered){ /* The input is buffered we have to do more *forreturningapointerU_TRUNCATED_CHAR_FOUND
*/ for(;;){
c = *temp++; if(buf->remaining==0){ return nullptr; /* end of file is reached return nullptr */
} if(temp>=buf->bufLimit && buf->currentPos == buf->buffer){
*err= U_TRUNCATED_CHAR_FOUND; return nullptr;
}else{
ucbuf_fillucbuf(buf,err); if(U_FAILURE(*err)){ return nullptr;
}
} /* *AccordingtoTR13readLinefunctionsmustinterpret *CR,CR+LF,LF,NEL,PS,LSorFFaslineseperators
*/ /* Windows CR LF */ if(c ==0x0d && temp <= buf->bufLimit && *temp == 0x0a ){
*len = (int32_t)(temp++ - buf->currentPos);
savePos = buf->currentPos;
buf->currentPos = temp; return savePos;
} /* else */
if (temp>=buf->bufLimit|| ucbuf_isCharNewLine(c)){ /* Unipad inserts 2028 line separators! */
*len = (int32_t)(temp - buf->currentPos);
savePos = buf->currentPos;
buf->currentPos = temp; return savePos;
}
}
}else{ /* we know that all input is read into the internal *buffersowecansafelyreturnpointers
*/ for(;;){
c = *temp++;
if(buf->currentPos==buf->bufLimit){ return nullptr; /* end of file is reached return nullptr */
} /* Windows CR LF */ if(c ==0x0d && temp <= buf->bufLimit && *temp == 0x0a ){
*len = (int32_t)(temp++ - buf->currentPos);
savePos = buf->currentPos;
buf->currentPos = temp; return savePos;
} /* else */ if (temp>=buf->bufLimit|| ucbuf_isCharNewLine(c)) { /* Unipad inserts 2028 line separators! */
*len = (int32_t)(temp - buf->currentPos);
savePos = buf->currentPos;
buf->currentPos = temp; return savePos;
}
}
} /* not reached */ /* A compiler warning will appear if all paths don't contain a return statement. */ /* return nullptr;*/
} #endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet am 2026-09-30)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.