~ubuntu-branches/ubuntu/vivid/fribidi/vivid

« back to all changes in this revision

Viewing changes to fribidi_char_sets_iso8859_6.c

  • Committer: Bazaar Package Importer
  • Author(s): Lior Kaplan
  • Date: 2006-09-16 10:37:10 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20060916103710-1ktngzyx9azkujhl
Tags: 0.10.7-4
* Fix manual page name section (Closes: #368632)
* debian/control: Upgrade standards version to 3.7.2 (no changes needed).
* debian/copyright: Update Dov Grobgeld's contact address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* FriBidi - Library of BiDi algorithm
 
2
 * Copyright (C) 1999,2000 Dov Grobgeld, and
 
3
 * Copyright (C) 2001,2002 Behdad Esfahbod. 
 
4
 * 
 
5
 * This library is free software; you can redistribute it and/or 
 
6
 * modify it under the terms of the GNU Lesser General Public 
 
7
 * License as published by the Free Software Foundation; either 
 
8
 * version 2.1 of the License, or (at your option) any later version. 
 
9
 * 
 
10
 * This library is distributed in the hope that it will be useful, 
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 
13
 * Lesser General Public License for more details. 
 
14
 * 
 
15
 * You should have received a copy of the GNU Lesser General Public License 
 
16
 * along with this library, in a file named COPYING; if not, write to the 
 
17
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 
18
 * Boston, MA 02111-1307, USA  
 
19
 * 
 
20
 * For licensing issues, contact <dov@imagic.weizmann.ac.il> and 
 
21
 * <fwpg@sharif.edu>. 
 
22
 */
 
23
 
 
24
#include "fribidi_config.h"
 
25
#ifndef FRIBIDI_NO_CHARSETS
 
26
 
 
27
#include <string.h>
 
28
#include "fribidi.h"
 
29
 
 
30
#define ISO_HAMZA 0xc1
 
31
#define ISO_SUKUN 0xf2
 
32
 
 
33
#define UNI_HAMZA 0x0621
 
34
#define UNI_SUKUN 0x0652
 
35
 
 
36
FriBidiChar
 
37
fribidi_iso8859_6_to_unicode_c (char sch)
 
38
{
 
39
  unsigned char ch = (unsigned char) sch;
 
40
  if (ch >= ISO_HAMZA && ch <= ISO_SUKUN)
 
41
    return ch - ISO_HAMZA + UNI_HAMZA;
 
42
  else
 
43
    return ch;
 
44
}
 
45
 
 
46
int
 
47
fribidi_iso8859_6_to_unicode (char *s, int len, FriBidiChar *us)
 
48
{
 
49
  int i;
 
50
 
 
51
  for (i = 0; i < len + 1; i++)
 
52
    us[i] = fribidi_iso8859_6_to_unicode_c (s[i]);
 
53
 
 
54
  return len;
 
55
}
 
56
 
 
57
char
 
58
fribidi_unicode_to_iso8859_6_c (FriBidiChar uch)
 
59
{
 
60
  if (uch >= UNI_HAMZA && uch <= UNI_SUKUN)
 
61
    return (char) (uch - UNI_HAMZA + ISO_HAMZA);
 
62
  /* TODO: handle pre-composed and presentation chars */
 
63
  else if (uch < 256)
 
64
    return (char) uch;
 
65
  else if (uch == 0x060c)
 
66
    return (char) 0xac;
 
67
  else if (uch == 0x061b)
 
68
    return (char) 0xbb;
 
69
  else if (uch == 0x061f)
 
70
    return (char) 0xbf;
 
71
  else
 
72
    return '�';
 
73
}
 
74
 
 
75
int
 
76
fribidi_unicode_to_iso8859_6 (FriBidiChar *us, int length, char *s)
 
77
{
 
78
  int i;
 
79
 
 
80
  for (i = 0; i < length; i++)
 
81
    s[i] = fribidi_unicode_to_iso8859_6_c (us[i]);
 
82
  s[i] = 0;
 
83
 
 
84
  return length;
 
85
}
 
86
 
 
87
#endif