diff options
author | Neil <nyamatongwe@gmail.com> | 2015-01-13 09:44:35 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-01-13 09:44:35 +1100 |
commit | bcdda18c2aa062fea2f754cb600f0b4ef94b300b (patch) | |
tree | 2220dee16cde5dd5394521436e000a02a7d0d2df /src | |
parent | ae17fbc86661c895d08fad5416a1452bdef04d32 (diff) | |
download | scintilla-mirror-bcdda18c2aa062fea2f754cb600f0b4ef94b300b.tar.gz |
Using size_t instead of unsigned int for conversions to UTF16 for 64-bit
compatibility and to lessen the number of casts.
Diffstat (limited to 'src')
-rw-r--r-- | src/UniConversion.cxx | 14 | ||||
-rw-r--r-- | src/UniConversion.h | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx index d19828a52..dea069843 100644 --- a/src/UniConversion.cxx +++ b/src/UniConversion.cxx @@ -82,10 +82,10 @@ unsigned int UTF8CharLength(unsigned char ch) { } } -unsigned int UTF16Length(const char *s, unsigned int len) { - unsigned int ulen = 0; - unsigned int charLen; - for (unsigned int i=0; i<len;) { +size_t UTF16Length(const char *s, size_t len) { + size_t ulen = 0; + size_t charLen; + for (size_t i = 0; i<len;) { unsigned char ch = static_cast<unsigned char>(s[i]); if (ch < 0x80) { charLen = 1; @@ -103,10 +103,10 @@ unsigned int UTF16Length(const char *s, unsigned int len) { return ulen; } -unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) { - unsigned int ui=0; +size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen) { + size_t ui = 0; const unsigned char *us = reinterpret_cast<const unsigned char *>(s); - unsigned int i=0; + size_t i = 0; while ((i<len) && (ui<tlen)) { unsigned char ch = us[i++]; if (ch < 0x80) { diff --git a/src/UniConversion.h b/src/UniConversion.h index 760f50476..8c7ac4a27 100644 --- a/src/UniConversion.h +++ b/src/UniConversion.h @@ -19,8 +19,8 @@ const int unicodeReplacementChar = 0xFFFD; unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen); void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len); unsigned int UTF8CharLength(unsigned char ch); -unsigned int UTF16Length(const char *s, unsigned int len); -unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen); +size_t UTF16Length(const char *s, size_t len); +size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen); unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int tlen); unsigned int UTF16FromUTF32Character(unsigned int val, wchar_t *tbuf); |