Lines Matching defs:cch
48 * @param cch The max length of the string. (btw cch = cb)
52 * on success (cch = cb again). Optional.
54 DECLHIDDEN(int) rtUtf8Length(const char *psz, size_t cch, size_t *pcuc, size_t *pcchActual)
58 while (cch > 0)
80 RTStrAssertMsgFailed(("Invalid UTF-8 first byte: %.*Rhxs\n", RT_MIN(cch, 10), puch));
85 if (cb > cch)
87 RTStrAssertMsgFailed(("Invalid UTF-8 length: cb=%d cch=%d (%.*Rhxs)\n", cb, cch, RT_MIN(cch, 10), puch));
95 RTStrAssertMsgReturn((puch[5] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("6/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
97 RTStrAssertMsgReturn((puch[4] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("5/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
99 RTStrAssertMsgReturn((puch[3] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("4/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
101 RTStrAssertMsgReturn((puch[2] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("3/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
103 RTStrAssertMsgReturn((puch[1] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("2/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
119 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
128 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
136 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
143 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch),
146 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_CODE_POINT_SURROGATE);
152 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
157 cch -= cb;
164 cch--;
184 * @param cch The number of chars (the type char, so bytes if you like) to process of the UTF-8 string.
185 * The recoding will stop when cch or '\\0' is reached. Pass RTSTR_MAX to process up to '\\0'.
189 static int rtUtf8Decode(const char *psz, size_t cch, PRTUNICP paCps, size_t cCps)
194 while (cch > 0)
214 cch--;
225 cch -= 2;
233 cch -= 3;
242 cch -= 4;
252 cch -= 6;
264 cch -= 6;
283 RTDECL(int) RTStrUniLenEx(const char *psz, size_t cch, size_t *pcCps)
286 int rc = rtUtf8Length(psz, cch, &cCodePoints, NULL);
301 RTDECL(int) RTStrValidateEncodingEx(const char *psz, size_t cch, uint32_t fFlags)
312 int rc = rtUtf8Length(psz, cch, &cCpsIgnored, &cchActual);
319 if (cchActual == cch)
321 else if (cchActual < cch)
327 && cchActual >= cch)
503 * @param cch The max length of the string. (btw cch = cb)
507 static int rtUtf8CalcUtf16Length(const char *psz, size_t cch, size_t *pcwc)
511 while (cch > 0)
521 cch--;
539 RTStrAssertMsgFailed(("Invalid UTF-8 first byte: %.*Rhxs\n", RT_MIN(cch, 10), puch));
544 if (cb > cch)
546 RTStrAssertMsgFailed(("Invalid UTF-8 length: cb=%d cch=%d (%.*Rhxs)\n", cb, cch, RT_MIN(cch, 10), puch));
554 RTStrAssertMsgReturn((puch[5] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("6/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
556 RTStrAssertMsgReturn((puch[4] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("5/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
558 RTStrAssertMsgReturn((puch[3] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("4/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
560 RTStrAssertMsgReturn((puch[2] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("3/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
562 RTStrAssertMsgReturn((puch[1] & (RT_BIT(7) | RT_BIT(6))) == RT_BIT(7), ("2/%u: %.*Rhxs\n", cb, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
578 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
579 RTStrAssertMsgFailed(("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch));
588 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
589 RTStrAssertMsgFailed(("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch));
597 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
599 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_CANT_RECODE_AS_UTF16);
607 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch),
610 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_CODE_POINT_SURROGATE);
616 ("%u: cp=%#010RX32: %.*Rhxs\n", cb, uc, RT_MIN(cb + 10, cch), puch), VERR_INVALID_UTF8_ENCODING);
621 cch -= cb;
640 * @param cch The number of chars (the type char, so bytes if you like) to process of the UTF-8 string.
641 * The recoding will stop when cch or '\\0' is reached. Pass RTSTR_MAX to process up to '\\0'.
645 static int rtUtf8RecodeAsUtf16(const char *psz, size_t cch, PRTUTF16 pwsz, size_t cwc)
650 while (cch > 0)
670 cch--;
678 cch -= 2;
687 cch -= 3;
708 cch -= 4;
829 RTDECL(int) RTStrCalcUtf16LenEx(const char *psz, size_t cch, size_t *pcwc)
832 int rc = rtUtf8CalcUtf16Length(psz, cch, &cwc);
846 * @param pcch Where to store the length (excluding '\\0') of the UTF-8 string. (cch == cb, btw)
850 size_t cch = 0;
859 cch += RTStrCpSize(Cp); /* cannot fail */
863 *pcch = cch;
874 * will stop when cch or '\\0' is reached.
876 * @param cch The size of the UTF-8 buffer, excluding the terminator.
878 static int rtLatin1RecodeAsUtf8(const char *pszIn, size_t cchIn, char *psz, size_t cch)
889 if (RT_UNLIKELY(cch < cchCp))
895 cch -= cchCp;
920 size_t cch;
921 int rc = rtLatin1CalcUtf8Length(pszString, RTSTR_MAX, &cch);
927 char *pszResult = (char *)RTMemAllocTag(cch + 1, pszTag);
930 rc = rtLatin1RecodeAsUtf8(pszString, RTSTR_MAX, pszResult, cch);
947 RTDECL(int) RTLatin1ToUtf8ExTag(const char *pszString, size_t cchString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag)
971 if (cch > 0 && *ppsz)
974 if (RT_UNLIKELY(cch <= cchResult))
982 cch = RT_MAX(cch, cchResult + 1);
983 pszResult = (char *)RTStrAllocTag(cch, pszTag);
987 rc = rtLatin1RecodeAsUtf8(pszString, cchString, pszResult, cch - 1);
1007 size_t cch;
1008 int rc = rtLatin1CalcUtf8Length(psz, RTSTR_MAX, &cch);
1009 return RT_SUCCESS(rc) ? cch : 0;
1016 size_t cch;
1017 int rc = rtLatin1CalcUtf8Length(psz, cchIn, &cch);
1019 *pcch = RT_SUCCESS(rc) ? cch : ~(size_t)0;
1031 * @param cchIn The max length of the string. (btw cch = cb)
1037 size_t cch = 0;
1050 cch += cchCp;
1054 *pcch = cch;
1067 * The recoding will stop when cch or '\\0' is reached. Pass RTSTR_MAX to process up to '\\0'.
1069 * @param cch The number of characters the pszOut buffer can hold, excluding the terminator ('\\0').
1071 static int rtUtf8RecodeAsLatin1(const char *pszIn, size_t cchIn, char *psz, size_t cch)
1082 if (RT_UNLIKELY(cch < cchCp))
1088 cch -= cchCp;
1113 size_t cch;
1114 int rc = rtUtf8CalcLatin1Length(pszString, RTSTR_MAX, &cch);
1120 char *psz = (char *)RTMemAllocTag(cch + 1, pszTag);
1126 rc = rtUtf8RecodeAsLatin1(pszString, RTSTR_MAX, psz, cch);
1143 char **ppsz, size_t cch, size_t *pcch, const char *pszTag)
1167 if (cch > 0 && *ppsz)
1170 if (cch <= cchResult)
1178 cch = RT_MAX(cchResult + 1, cch);
1179 pszResult = (char *)RTMemAllocTag(cch, pszTag);
1186 rc = rtUtf8RecodeAsLatin1(pszString, cchString, pszResult, cch - 1);
1205 size_t cch;
1206 int rc = rtUtf8CalcLatin1Length(psz, RTSTR_MAX, &cch);
1207 return RT_SUCCESS(rc) ? cch : 0;
1214 size_t cch;
1215 int rc = rtUtf8CalcLatin1Length(psz, cchIn, &cch);
1217 *pcch = RT_SUCCESS(rc) ? cch : ~(size_t)0;
1398 size_t cch = *pcch;
1401 if (cch == 0)
1412 cch--;
1435 if (cb > cch)
1515 cch -= cb;
1525 (*pcch) = cch;