diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-29 16:04:01 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-29 16:04:01 +0100 |
commit | 88083f8c683c18f4de68a20c863a82a9da65db8f (patch) | |
tree | 926656892d9d80260da02ea8ea71031b140c51df /other-licenses/7zstub/src/Common/UTFConvert.cpp | |
parent | f999f544aad04069b03704d994a99352263f600b (diff) | |
parent | 843e4ceffd6ce21a6e6db37419335eafdc543e18 (diff) | |
download | UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar.gz UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar.lz UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar.xz UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.zip |
Merge branch 'master' into Sync-weave
Diffstat (limited to 'other-licenses/7zstub/src/Common/UTFConvert.cpp')
-rw-r--r-- | other-licenses/7zstub/src/Common/UTFConvert.cpp | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/other-licenses/7zstub/src/Common/UTFConvert.cpp b/other-licenses/7zstub/src/Common/UTFConvert.cpp deleted file mode 100644 index 5414e6b8d..000000000 --- a/other-licenses/7zstub/src/Common/UTFConvert.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// UTFConvert.cpp
-
-#include "StdAfx.h"
-
-#include "UTFConvert.h"
-#include "Types.h"
-
-static Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
-// These functions are for UTF8 <-> UTF16 conversion.
-
-bool ConvertUTF8ToUnicode(const AString &src, UString &dest)
-{
- dest.Empty();
- for(int i = 0; i < src.Length();)
- {
- Byte c = (Byte)src[i++];
- if (c < 0x80)
- {
- dest += (wchar_t)c;
- continue;
- }
- if(c < 0xC0)
- return false;
- int numAdds;
- for (numAdds = 1; numAdds < 5; numAdds++)
- if (c < kUtf8Limits[numAdds])
- break;
- UInt32 value = (c - kUtf8Limits[numAdds - 1]);
- do
- {
- if (i >= src.Length())
- return false;
- Byte c2 = (Byte)src[i++];
- if (c2 < 0x80 || c2 >= 0xC0)
- return false;
- value <<= 6;
- value |= (c2 - 0x80);
- numAdds--;
- }
- while(numAdds > 0);
- if (value < 0x10000)
- dest += (wchar_t)(value);
- else
- {
- value -= 0x10000;
- if (value >= 0x100000)
- return false;
- dest += (wchar_t)(0xD800 + (value >> 10));
- dest += (wchar_t)(0xDC00 + (value & 0x3FF));
- }
- }
- return true;
-}
-
-bool ConvertUnicodeToUTF8(const UString &src, AString &dest)
-{
- dest.Empty();
- for(int i = 0; i < src.Length();)
- {
- UInt32 value = (UInt32)src[i++];
- if (value < 0x80)
- {
- dest += (char)value;
- continue;
- }
- if (value >= 0xD800 && value < 0xE000)
- {
- if (value >= 0xDC00)
- return false;
- if (i >= src.Length())
- return false;
- UInt32 c2 = (UInt32)src[i++];
- if (c2 < 0xDC00 || c2 >= 0xE000)
- return false;
- value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
- }
- int numAdds;
- for (numAdds = 1; numAdds < 5; numAdds++)
- if (value < (((UInt32)1) << (numAdds * 5 + 6)))
- break;
- dest += (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
- do
- {
- numAdds--;
- dest += (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
- }
- while(numAdds > 0);
- }
- return true;
-}
|