Print utf8 text.
This commit is contained in:
parent
4600413c2e
commit
05f6883a1a
5
md380.c
5
md380.c
@ -312,12 +312,11 @@ static void print_unicode(FILE *out, const uint16_t *text, unsigned nchars, int
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i=0; i<nchars && *text; i++) {
|
for (i=0; i<nchars && *text; i++) {
|
||||||
//TODO: convert to utf8
|
putc_utf8(*text++, out);
|
||||||
putc(*text++, out);
|
|
||||||
}
|
}
|
||||||
if (fill_flag) {
|
if (fill_flag) {
|
||||||
for (; i<nchars; i++) {
|
for (; i<nchars; i++) {
|
||||||
putc(' ', out);
|
putc_utf8(' ', out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
util.c
23
util.c
@ -185,3 +185,26 @@ void print_options(FILE *out, const char **tab, int num, const char *info)
|
|||||||
}
|
}
|
||||||
fprintf(out, "\n");
|
fprintf(out, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Write Unicode symbol to file.
|
||||||
|
// Convert to UTF-8 encoding:
|
||||||
|
// 00000000.0xxxxxxx -> 0xxxxxxx
|
||||||
|
// 00000xxx.xxyyyyyy -> 110xxxxx, 10yyyyyy
|
||||||
|
// xxxxyyyy.yyzzzzzz -> 1110xxxx, 10yyyyyy, 10zzzzzz
|
||||||
|
//
|
||||||
|
void putc_utf8(unsigned short ch, FILE *out)
|
||||||
|
{
|
||||||
|
if (ch < 0x80) {
|
||||||
|
putc (ch, out);
|
||||||
|
|
||||||
|
} else if (ch < 0x800) {
|
||||||
|
putc (ch >> 6 | 0xc0, out);
|
||||||
|
putc ((ch & 0x3f) | 0x80, out);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
putc (ch >> 12 | 0xe0, out);
|
||||||
|
putc (((ch >> 6) & 0x3f) | 0x80, out);
|
||||||
|
putc ((ch & 0x3f) | 0x80, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
5
util.h
5
util.h
@ -119,3 +119,8 @@ void print_options(FILE *out, const char **tab, int num, const char *info);
|
|||||||
// Print list of all squelch tones.
|
// Print list of all squelch tones.
|
||||||
//
|
//
|
||||||
void print_squelch_tones(FILE *out, int normal_only);
|
void print_squelch_tones(FILE *out, int normal_only);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Write Unicode symbol to a file in UTF-8 encoding.
|
||||||
|
//
|
||||||
|
void putc_utf8(unsigned short ch, FILE *out);
|
||||||
|
5
uv380.c
5
uv380.c
@ -328,8 +328,7 @@ static void print_unicode(FILE *out, const uint16_t *text, unsigned nchars, int
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i=0; i<nchars && *text; i++) {
|
for (i=0; i<nchars && *text; i++) {
|
||||||
//TODO: convert to utf8
|
putc_utf8(*text++, out);
|
||||||
putc(*text++, out);
|
|
||||||
}
|
}
|
||||||
if (fill_flag) {
|
if (fill_flag) {
|
||||||
for (; i<nchars; i++) {
|
for (; i<nchars; i++) {
|
||||||
@ -1144,7 +1143,7 @@ badtx: fprintf(stderr, "Bad transmit frequency.\n");
|
|||||||
if (! is_valid_frequency(tx_mhz))
|
if (! is_valid_frequency(tx_mhz))
|
||||||
goto badtx;
|
goto badtx;
|
||||||
|
|
||||||
//TODO
|
//TODO: parse CTSS/DCS tone
|
||||||
tmode = 0;
|
tmode = 0;
|
||||||
|
|
||||||
if (strcasecmp("High", power_str) == 0) {
|
if (strcasecmp("High", power_str) == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user