~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to src/expat/xmlwf/codepage.c

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-01-07 13:59:25 UTC
  • mfrom: (1.1.9) (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120107135925-2601miy9ullcon9j
Tags: 2.8.12.1-6ubuntu1
* Resync from Debian, changes that were kept:
  - debian/rules: re-enable mediactrl. This allows libwx_gtk2u_media-2.8 to be
    built, as this is required by some applications (LP: #632984)
  - debian/control: Build-dep on libxt-dev for mediactrl.
  - Patches
    + fix-bashism-in-example
* Add conflict on python-wxgtk2.8 (<< 2.8.12.1-6ubuntu1~) to python-wxversion
  to guarantee upgrade ordering when moving from pycentral to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2
 
   See the file COPYING for copying permission.
3
 
*/
4
 
 
5
 
#include "codepage.h"
6
 
 
7
 
#ifdef WIN32
8
 
#define STRICT 1
9
 
#define WIN32_LEAN_AND_MEAN 1
10
 
 
11
 
#include <windows.h>
12
 
 
13
 
int
14
 
codepageMap(int cp, int *map)
15
 
{
16
 
  int i;
17
 
  CPINFO info;
18
 
  if (!GetCPInfo(cp, &info) || info.MaxCharSize > 2)
19
 
    return 0;
20
 
  for (i = 0; i < 256; i++)
21
 
    map[i] = -1;
22
 
  if (info.MaxCharSize > 1) {
23
 
    for (i = 0; i < MAX_LEADBYTES; i++) {
24
 
      int j, lim;
25
 
      if (info.LeadByte[i] == 0 && info.LeadByte[i + 1] == 0)
26
 
        break;
27
 
      lim = info.LeadByte[i + 1];
28
 
      for (j = info.LeadByte[i]; j < lim; j++)
29
 
        map[j] = -2;
30
 
    }
31
 
  }
32
 
  for (i = 0; i < 256; i++) {
33
 
   if (map[i] == -1) {
34
 
     char c = (char)i;
35
 
     unsigned short n;
36
 
     if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
37
 
                             &c, 1, &n, 1) == 1)
38
 
       map[i] = n;
39
 
   }
40
 
  }
41
 
  return 1;
42
 
}
43
 
 
44
 
int
45
 
codepageConvert(int cp, const char *p)
46
 
{
47
 
  unsigned short c;
48
 
  if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
49
 
                          p, 2, &c, 1) == 1)
50
 
    return c;
51
 
  return -1;
52
 
}
53
 
 
54
 
#else /* not WIN32 */
55
 
 
56
 
int
57
 
codepageMap(int cp, int *map)
58
 
{
59
 
  return 0;
60
 
}
61
 
 
62
 
int
63
 
codepageConvert(int cp, const char *p)
64
 
{
65
 
  return -1;
66
 
}
67
 
 
68
 
#endif /* not WIN32 */