Skip to content

Commit 007d6fb

Browse files
committed
Add TODO and format lib/converters/utf32be.h.
1 parent 5540f92 commit 007d6fb

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1. Implement the //NON_IDENTICAL_DISCARD suffix from POSIX:2024.
2+
2. Add translit support.

lib/converters/utf32be.h

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,44 @@
2727

2828
#include "reiconv_defines.h"
2929

30-
/* Specification: Unicode 3.1 Standard Annex #19 */
30+
// Specification: Unicode 3.1 Standard Annex #19
3131

32-
static int
33-
utf32be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
32+
static int utf32be_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
3433
{
35-
if (n >= 4) {
36-
ucs4_t wc = ((ucs4_t) s[0] << 24)
37-
+ ((ucs4_t) s[1] << 16)
38-
+ ((ucs4_t) s[2] << 8)
39-
+ (ucs4_t) s[3];
40-
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) {
41-
*pwc = wc;
42-
return 4;
43-
} else
44-
return RET_ILSEQ;
45-
}
46-
return RET_TOOFEW(0);
34+
if (n >= 4)
35+
{
36+
ucs4_t wc = ((ucs4_t)s[0] << 24) + ((ucs4_t)s[1] << 16) + ((ucs4_t)s[2] << 8) + (ucs4_t)s[3];
37+
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
38+
{
39+
*pwc = wc;
40+
return 4;
41+
}
42+
else
43+
{
44+
return RET_ILSEQ;
45+
}
46+
}
47+
return RET_TOOFEW(0);
4748
}
4849

49-
static int
50-
utf32be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
50+
static int utf32be_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
5151
{
52-
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) {
53-
if (n >= 4) {
54-
r[0] = 0;
55-
r[1] = (unsigned char) (wc >> 16);
56-
r[2] = (unsigned char) (wc >> 8);
57-
r[3] = (unsigned char) wc;
58-
return 4;
59-
} else
60-
return RET_TOOSMALL;
61-
}
62-
return RET_ILUNI;
52+
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
53+
{
54+
if (n >= 4)
55+
{
56+
r[0] = 0;
57+
r[1] = (unsigned char)(wc >> 16);
58+
r[2] = (unsigned char)(wc >> 8);
59+
r[3] = (unsigned char)wc;
60+
return 4;
61+
}
62+
else
63+
{
64+
return RET_TOOSMALL;
65+
}
66+
}
67+
return RET_ILUNI;
6368
}
6469

6570
#endif /* _UTF32BE_H_ */

0 commit comments

Comments
 (0)