summaryrefslogtreecommitdiff
path: root/ascii2map.c
diff options
context:
space:
mode:
Diffstat (limited to 'ascii2map.c')
-rw-r--r--ascii2map.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/ascii2map.c b/ascii2map.c
index 30a2c44..f24cb77 100644
--- a/ascii2map.c
+++ b/ascii2map.c
@@ -105,6 +105,24 @@ static void EndOutput(FILE *fp)
}
+static unsigned CodePoint(char c)
+{
+ int offset = c - code_point;
+
+ if (offset < 0)
+ {
+ offset = 0;
+ }
+
+ if (offset > 255)
+ {
+ offset = 255;
+ }
+
+ return (unsigned)offset;
+}
+
+
static void Output(FILE *fp, char c)
{
static int column;
@@ -138,7 +156,7 @@ static void Output(FILE *fp, char c)
}
else
{
- fprintf(fp, "%u", c - code_point);
+ fprintf(fp, "%u", CodePoint(c));
}
break;
@@ -150,7 +168,7 @@ static void Output(FILE *fp, char c)
}
else
{
- putc(c - code_point, fp);
+ putc(CodePoint(c), fp);
}
break;
@@ -177,7 +195,7 @@ static void Output(FILE *fp, char c)
}
else
{
- fprintf(fp, "%u", c - code_point);
+ fprintf(fp, "%u", CodePoint(c));
}
break;