summaryrefslogtreecommitdiff
path: root/xfa/fgas/crt/fgas_codepage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas/crt/fgas_codepage.cpp')
-rw-r--r--xfa/fgas/crt/fgas_codepage.cpp124
1 files changed, 0 insertions, 124 deletions
diff --git a/xfa/fgas/crt/fgas_codepage.cpp b/xfa/fgas/crt/fgas_codepage.cpp
index cae2dd7234..c1a4322883 100644
--- a/xfa/fgas/crt/fgas_codepage.cpp
+++ b/xfa/fgas/crt/fgas_codepage.cpp
@@ -68,127 +68,3 @@ uint16_t FX_GetCodePageFromCharset(uint8_t charset) {
} while (iStart <= iEnd);
return 0xFFFF;
}
-
-void FX_SwapByteOrder(wchar_t* pStr, int32_t iLength) {
- ASSERT(pStr);
-
- if (iLength < 0)
- iLength = FXSYS_wcslen(pStr);
-
- uint16_t wch;
- if (sizeof(wchar_t) > 2) {
- while (iLength-- > 0) {
- wch = (uint16_t)*pStr;
- wch = (wch >> 8) | (wch << 8);
- wch &= 0x00FF;
- *pStr++ = wch;
- }
- return;
- }
-
- while (iLength-- > 0) {
- wch = (uint16_t)*pStr;
- wch = (wch >> 8) | (wch << 8);
- *pStr++ = wch;
- }
-}
-
-void FX_UTF16ToWChar(void* pBuffer, int32_t iLength) {
- ASSERT(pBuffer && iLength > 0);
- if (sizeof(wchar_t) == 2)
- return;
-
- uint16_t* pSrc = static_cast<uint16_t*>(pBuffer);
- wchar_t* pDst = static_cast<wchar_t*>(pBuffer);
- while (--iLength >= 0)
- pDst[iLength] = static_cast<wchar_t>(pSrc[iLength]);
-}
-
-int32_t FX_DecodeString(uint16_t wCodePage,
- const char* pSrc,
- int32_t* pSrcLen,
- wchar_t* pDst,
- int32_t* pDstLen,
- bool bErrBreak) {
- if (wCodePage == FX_CODEPAGE_UTF8)
- return FX_UTF8Decode(pSrc, pSrcLen, pDst, pDstLen);
- return -1;
-}
-
-int32_t FX_UTF8Decode(const char* pSrc,
- int32_t* pSrcLen,
- wchar_t* pDst,
- int32_t* pDstLen) {
- if (!pSrcLen || !pDstLen)
- return -1;
-
- int32_t iSrcLen = *pSrcLen;
- if (iSrcLen < 1) {
- *pSrcLen = *pDstLen = 0;
- return 1;
- }
-
- int32_t iDstLen = *pDstLen;
- bool bValidDst = (pDst && iDstLen > 0);
- uint32_t dwCode = 0;
- int32_t iPending = 0;
- int32_t iSrcNum = 0;
- int32_t iDstNum = 0;
- int32_t iIndex = 0;
- int32_t k = 1;
- while (iIndex < iSrcLen) {
- uint8_t byte = static_cast<uint8_t>(*(pSrc + iIndex));
- if (byte < 0x80) {
- iPending = 0;
- k = 1;
- iDstNum++;
- iSrcNum += k;
- if (bValidDst) {
- *pDst++ = byte;
- if (iDstNum >= iDstLen)
- break;
- }
- } else if (byte < 0xc0) {
- if (iPending < 1)
- break;
-
- iPending--;
- dwCode |= (byte & 0x3f) << (iPending * 6);
- if (iPending == 0) {
- iDstNum++;
- iSrcNum += k;
- if (bValidDst) {
- *pDst++ = dwCode;
- if (iDstNum >= iDstLen)
- break;
- }
- }
- } else if (byte < 0xe0) {
- iPending = 1;
- k = 2;
- dwCode = (byte & 0x1f) << 6;
- } else if (byte < 0xf0) {
- iPending = 2;
- k = 3;
- dwCode = (byte & 0x0f) << 12;
- } else if (byte < 0xf8) {
- iPending = 3;
- k = 4;
- dwCode = (byte & 0x07) << 18;
- } else if (byte < 0xfc) {
- iPending = 4;
- k = 5;
- dwCode = (byte & 0x03) << 24;
- } else if (byte < 0xfe) {
- iPending = 5;
- k = 6;
- dwCode = (byte & 0x01) << 30;
- } else {
- break;
- }
- iIndex++;
- }
- *pSrcLen = iSrcNum;
- *pDstLen = iDstNum;
- return 1;
-}