Commit 45d01bdf authored by Simon Middleton's avatar Simon Middleton
Browse files

Recreated acorn.c to hold new encoding cdAcornFuzzy. This writes an

Acorn Latin1 encoding using fuzzy mapping to get the greatest number
of displayable characters. Reads as Acorn.Latin1.

Version 0.07. Tagged as 'Unicode-0_07'
parent d24d7328
......@@ -87,7 +87,8 @@ OBJS = autojp.o \
enc_utf8.o \
enc_ascii.o \
enc_utf16.o \
enc_ucs4.o
enc_ucs4.o \
acorn.o
OBJSZ = \
oz.autojp \
......@@ -101,7 +102,9 @@ OBJSZ = \
oz.enc_utf8 \
oz.enc_ascii \
oz.enc_utf16 \
oz.enc_ucs4
oz.enc_ucs4 \
oz.acorn
OBJSD = \
od.autojp \
......@@ -115,7 +118,8 @@ OBJSD = \
od.enc_utf8 \
od.enc_ascii \
od.enc_utf16 \
od.enc_ucs4
od.enc_ucs4 \
od.acorn
HDRS = autojp.h charsets.h encoding.h iso10646.h languages.h unictype.h utf8.h
......
/* (0.06)
/* (0.07)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.06
#define Module_MajorVersion_CMHG 0.07
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Nov 1997
#define Module_Date_CMHG 02 Dec 1997
#define Module_MajorVersion "0.06"
#define Module_MajorVersion "0.07"
#define Module_MinorVersion ""
#define Module_Date "25 Nov 1997"
#define Module_Date "02 Dec 1997"
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include "encpriv.h"
#include "eightbit.h"
#include "acorn.h"
typedef struct
{
UCS2 u;
char c;
} key_pair;
static key_pair fuzzy_specials[] =
{
/* exact matches */
{ 0x0174, 0x81 },
{ 0x0175, 0x82 },
{ 0x0176, 0x85 },
{ 0x0177, 0x86 },
{ 0x2026, 0x8C },
{ 0x2122, 0x8D },
{ 0x2030, 0x8E },
{ 0x2022, 0x8F },
{ 0x2018, 0x90 },
{ 0x2019, 0x91 },
{ 0x2039, 0x92 },
{ 0x203A, 0x93 },
{ 0x201C, 0x94 },
{ 0x201D, 0x95 },
{ 0x201E, 0x96 },
{ 0x2013, 0x97 },
{ 0x2014, 0x98 },
{ 0x2212, 0x99 },
{ 0x0152, 0x9A },
{ 0x0153, 0x9B },
{ 0x2020, 0x9C },
{ 0x2021, 0x9D },
{ 0xFB01, 0x9E },
{ 0xFB02, 0x9F },
/* less exact matches */
{ 0x201A, ',' }, /* sq lower */
{ 0x0192, 'f' }, /* guilder */
{ 0x02C6, '^' }, /* circumflex */
{ 0x0160, 'S' }, /* S hacek */
{ 0x02DC, '~' }, /* tilde */
{ 0x0161, 's' }, /* s hacek */
{ 0, 0 }
};
static int acorn_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
{
int c;
if ( --(*bufsize) < 0 || !s)
return 0;
if (u < 0x100)
c = u; /* all Latin1 go straight through */
else
{
key_pair *kp;
c = 143; /* bullet character */
for (kp = fuzzy_specials; kp->u; kp++)
{
if (kp->u == u)
{
c = kp->c;
break;
}
}
}
(*s)[0] = c;
(*s)++;
return 1;
}
EncodingPriv enc_acorn =
{
eightbit_read,
eightbit_reset,
sizeof(EightBit_Encoding) - sizeof(EncodingPriv),
eightbit_delete,
0,
acorn_write
};
......@@ -18,12 +18,6 @@
#include "eightbit.h"
typedef struct EightBit_Encoding
{
EncodingPriv e;
encoding_table table; /* 128-entry table for codes 0x80-0xFF */
} EightBit_Encoding;
/*
* Routines for KOI-8R (Cyrillic)
* Number: 2084
......@@ -31,7 +25,7 @@ typedef struct EightBit_Encoding
* csKOI8R
*/
static int eightbit_reset(Encoding *e, int for_encoding)
int eightbit_reset(Encoding *e, int for_encoding)
{
EightBit_Encoding *ee = (EightBit_Encoding *) e;
......@@ -41,7 +35,7 @@ static int eightbit_reset(Encoding *e, int for_encoding)
return ee->table != NULL;
}
static unsigned int eightbit_read(EncodingPriv *e,
unsigned int eightbit_read(EncodingPriv *e,
encoding_read_callback_fn ucs_out,
const char *s,
unsigned int n,
......@@ -67,7 +61,7 @@ static unsigned int eightbit_read(EncodingPriv *e,
return n - count;
}
static int eightbit_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
int eightbit_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
{
EightBit_Encoding *ee = (EightBit_Encoding *) e;
int i, c;
......@@ -87,7 +81,7 @@ static int eightbit_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
return 1;
}
static void eightbit_delete(EncodingPriv *e)
void eightbit_delete(EncodingPriv *e)
{
EightBit_Encoding *ee = (EightBit_Encoding *) e;
if (ee->table)
......
......@@ -26,6 +26,7 @@
#include "enc_utf8.h"
#include "enc_utf16.h"
#include "enc_ucs4.h"
#include "acorn.h"
#include "charsets.h"
#include "languages.h"
......@@ -50,6 +51,7 @@ static char version[] = "Unicode library " Module_MajorVersion " " Module_Date "
#define ENC_utf16 9
#define ENC_ucs4 10
#define ENC_iso2022_shifts 11
#define ENC_acorn 12
static EncList enclist[] =
{
......@@ -115,6 +117,7 @@ static EncList enclist[] =
{ csSami, 1, "/ISO-8859-15/ISO-IR-197/", lang_ENGLISH, (EncodingPriv *)ENC_iso8859, "\x1B\x2D\x5D" }, /* Select Sami right half */
{ csISOLatin13, 1, "/ISO-8859-13/", lang_ENGLISH, (EncodingPriv *)ENC_iso8859, "\x1B\x2D\x59" }, /* Select Baltic Rim right half */
{ csAcornLatin1, 1, "/X-ACORN-LATIN1/", lang_ENGLISH, (EncodingPriv *)ENC_eightbit, "Acorn.Latin1" },
{ csAcornFuzzy, 1, "/X-ACORN-FUZZY/", lang_ENGLISH, (EncodingPriv *)ENC_acorn, "Acorn.Latin1" },
{ 0, 0, NULL, NULL }
};
......@@ -169,6 +172,9 @@ static void fixup(void)
case ENC_iso2022_shifts:
ep->encoding = &enc_iso2022_shifts;
break;
case ENC_acorn:
ep->encoding = &enc_acorn;
break;
}
}
}
......
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
extern EncodingPriv enc_acorn;
......@@ -244,6 +244,7 @@
#define csEUCorShiftJIS 4005
#define csAcornLatin1 5001
#define csAcornFuzzy 5002
#endif
......
......@@ -13,3 +13,18 @@
* limitations under the License.
*/
extern EncodingPriv enc_eightbit;
typedef struct EightBit_Encoding
{
EncodingPriv e;
encoding_table table; /* 128-entry table for codes 0x80-0xFF */
} EightBit_Encoding;
extern int eightbit_reset(Encoding *e, int for_encoding);
extern unsigned int eightbit_read(EncodingPriv *e,
encoding_read_callback_fn ucs_out,
const char *s,
unsigned int n,
void *handle);
extern int eightbit_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize);
extern void eightbit_delete(EncodingPriv *e);
......@@ -41,7 +41,8 @@ Objects = autojp.o unictype.o \
enc_utf8.o \
enc_ascii.o \
enc_utf16.o \
enc_ucs4.o
enc_ucs4.o \
acorn.o
ObjectsD = autojp.od unictype.od \
utf8.od \
......@@ -53,7 +54,8 @@ ObjectsD = autojp.od unictype.od \
enc_utf8.od \
enc_ascii.od \
enc_utf16.od \
enc_ucs4.od
enc_ucs4.od \
acorn.od
ObjectsZ = autojp.oz unictype.oz \
utf8.oz \
......@@ -65,7 +67,8 @@ ObjectsZ = autojp.oz unictype.oz \
enc_utf8.oz \
enc_ascii.oz \
enc_utf16.oz \
enc_ucs4.oz
enc_ucs4.oz \
acorn.oz
all: ucodelib
......
......@@ -35,6 +35,7 @@ wantlink ../c/enc_utf8 enc_utf8.c
wantlink ../c/enc_ascii enc_ascii.c
wantlink ../c/enc_utf16 enc_utf16.c
wantlink ../c/enc_ucs4 enc_ucs4.c
wantlink ../c/acorn acorn.c
wantlink ../h/utf8 utf8.h
wantlink ../h/encoding encoding.h
......@@ -46,4 +47,5 @@ wantlink ../h/enc_utf8 enc_utf8.h
wantlink ../h/enc_ascii enc_ascii.h
wantlink ../h/enc_utf16 enc_utf16.h
wantlink ../h/enc_ucs4 enc_ucs4.h
wantlink ../h/acorn acorn.h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment