File: jis0208-extra.c

package info (click to toggle)
libmoe 1.5.7-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 6,772 kB
  • ctags: 267,602
  • sloc: ansic: 478,515; perl: 2,318; makefile: 201; sh: 22
file content (53 lines) | stat: -rw-r--r-- 855 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "mb.h"

static unsigned int j2u[] = {
#include "jis0208-to-ucs-extra.h"
};

size_t
mb_jisx0208_to_ucs_extra(mb_wchar_t *ws, mb_wchar_t *ws_end, mb_info_t *info)
{
  size_t n;
  unsigned int wc1;

  for (n = 0 ; ws < ws_end ; ++ws)
    if (bt_search(*ws, j2u, &wc1) != bt_failure) {
      *ws = wc1;
      ++n;
    }

  return n;
}

static unsigned int u2j[] = {
#include "ucs-to-jis0208-extra.h"
};

size_t
mb_ucs_to_jisx0208_extra(mb_wchar_t *ws, mb_wchar_t *ws_end, mb_info_t *info)
{
  size_t n;
  unsigned int ucs, wc1;

  for (n = 0 ; ws < ws_end ; ++ws) {
    if (*ws & MB_NON_UCS_MARK) {
      mb_wchar_t wc;

      wc = *ws;

      if (!mb_conv_to_ucs(&wc, &wc + 1, info))
	continue;

      ucs = wc;
    }
    else
      ucs = *ws;

    if (bt_search(ucs, u2j, &wc1) != bt_failure) {
      *ws = wc1;
      ++n;
    }
  }

  return n;
}