~ubuntu-branches/ubuntu/gutsy/lv/gutsy

« back to all changes in this revision

Viewing changes to src/iso8859.c

  • Committer: Bazaar Package Importer
  • Author(s): GOTO Masanori
  • Date: 2003-11-16 01:21:59 UTC
  • Revision ID: james.westby@ubuntu.com-20031116012159-wpu27qhoxzskmjy0
Tags: upstream-4.50
ImportĀ upstreamĀ versionĀ 4.50

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * iso8859.c
 
3
 *
 
4
 * All rights reserved. Copyright (C) 1996 by NARITA Tomio.
 
5
 * $Id: iso8859.c,v 1.3 2003/11/13 03:08:19 nrt Exp $
 
6
 */
 
7
/*
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
21
 */
 
22
 
 
23
#include <stdio.h>
 
24
 
 
25
#include <import.h>
 
26
#include <encode.h>
 
27
#include <unimap.h>
 
28
#include <begin.h>
 
29
#include <iso8859.h>
 
30
 
 
31
/*
 
32
 * iso-8859-*
 
33
 *
 
34
 * one pre-designated 8bit charset uses G1.
 
35
 */
 
36
public void EncodeISO8859( i_str_t *istr, int head, int tail,
 
37
                          byte codingSystem, boolean_t binary )
 
38
{
 
39
  int idx, attr;
 
40
  ic_t ic;
 
41
  byte cset, csetG1 = ASCII;
 
42
 
 
43
  csetG1 = cTable[ (int)codingSystem ].state.cset[ G1 ];
 
44
 
 
45
  for( idx = head ; idx < tail ; idx++ ){
 
46
    cset = istr[ idx ].charset;
 
47
    ic = istr[ idx ].c;
 
48
    attr = (int)istr[ idx ].attr << 8;
 
49
#ifndef MSDOS /* IF NOT DEFINED */
 
50
    if( UNICODE == cset )
 
51
      ic = UNItoISO8859( ic, &cset, codingSystem );
 
52
#endif /* MSDOS */
 
53
    if( cset < PSEUDO ){
 
54
      if( ASCII == cset ){
 
55
        EncodeAddChar( attr, ic );
 
56
      } else if( csetG1 == cset ){
 
57
        EncodeAddChar( attr, 0x80 | ic );
 
58
      } else {
 
59
        if( FALSE == EncodeAddInvalid( attr, ic, cset ) )
 
60
          break;
 
61
      }
 
62
    } else if( FALSE == EncodeAddPseudo( attr, ic, cset, binary ) ){
 
63
      break;
 
64
    }
 
65
  }
 
66
}