mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-09 20:46:24 +02:00
Merge pull request #211 from unknownbrackets/ccc
Add encodeUnits() to utf8/utf16/sjis.
This commit is contained in:
commit
f26bb015b0
5 files changed
+37
-2
No files matched your search
+3
-1
@@ -287,6 +287,8 @@
|
||||
<ClInclude Include="util\random\perlin.h" />
|
||||
<ClInclude Include="util\random\rng.h" />
|
||||
<ClInclude Include="util\text\parsers.h" />
|
||||
<ClInclude Include="util\text\shiftjis.h" />
|
||||
<ClInclude Include="util\text\utf16.h" />
|
||||
<ClInclude Include="util\text\utf8.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -776,4 +778,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -338,6 +338,12 @@
|
||||
<ClInclude Include="math\fast\fast_matrix.h">
|
||||
<Filter>math\fast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="util\text\utf16.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="util\text\shiftjis.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="gfx\gl_debug_log.cpp">
|
||||
|
||||
@@ -127,6 +127,13 @@ struct ShiftJIS {
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int encodeUnits(uint32_t j) {
|
||||
if ((j & ~0xFF) == 0) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *c_;
|
||||
int index_;
|
||||
|
||||
+9
-1
@@ -42,7 +42,7 @@ public:
|
||||
return len;
|
||||
}
|
||||
|
||||
int byteIndex() const {
|
||||
int shortIndex() const {
|
||||
return index_;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static int encodeUnits(uint32_t u) {
|
||||
if (u >= 0x10000) {
|
||||
return 2;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const uint16_t *c_;
|
||||
int index_;
|
||||
|
||||
@@ -44,6 +44,18 @@ public:
|
||||
static int encode(char *dest, uint32_t ch) {
|
||||
return u8_wc_toutf8(dest, ch);
|
||||
}
|
||||
static int encodeUnits(uint32_t ch) {
|
||||
if (ch < 0x80) {
|
||||
return 1;
|
||||
} else if (ch < 0x800) {
|
||||
return 2;
|
||||
} else if (ch < 0x10000) {
|
||||
return 3;
|
||||
} else if (ch < 0x110000) {
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *c_;
|
||||
|
||||
Reference in new issue
Block a user