File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ int32_t NFDi_UTF8_Strlen( const nfdchar_t *str )
113
113
int32_t character_count = 0 ;
114
114
int32_t i = 0 ; /* Counter used to iterate over string. */
115
115
nfdchar_t maybe_bom [4 ];
116
+ unsigned char c ;
116
117
117
118
/* If there is UTF-8 BOM ignore it. */
118
119
if (strlen (str ) > 2 )
@@ -125,17 +126,18 @@ int32_t NFDi_UTF8_Strlen( const nfdchar_t *str )
125
126
126
127
while (str [i ])
127
128
{
128
- if (str [i ] >> 7 == 0 )
129
+ c = (unsigned char )str [i ];
130
+ if (c >> 7 == 0 )
129
131
{
130
132
/* If bit pattern begins with 0 we have ascii character. */
131
133
++ character_count ;
132
134
}
133
- else if (str [ i ] >> 6 == 3 )
135
+ else if (c >> 6 == 3 )
134
136
{
135
137
/* If bit pattern begins with 11 it is beginning of UTF-8 byte sequence. */
136
138
++ character_count ;
137
139
}
138
- else if (str [ i ] >> 6 == 2 )
140
+ else if (c >> 6 == 2 )
139
141
; /* If bit pattern begins with 10 it is middle of utf-8 byte sequence. */
140
142
else
141
143
{
You can’t perform that action at this time.
0 commit comments