[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[formatting i18n 04/14] i18n: New function recode_byte().
From: |
Ben Pfaff |
Subject: |
[formatting i18n 04/14] i18n: New function recode_byte(). |
Date: |
Sat, 19 Feb 2011 17:42:16 -0800 |
---
src/language/data-io/print.c | 4 ++--
src/libpspp/i18n.c | 16 +++++++++++++++-
src/libpspp/i18n.h | 2 ++
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c
index 1bcd047..ada59c3 100644
--- a/src/language/data-io/print.c
+++ b/src/language/data-io/print.c
@@ -454,7 +454,7 @@ print_trns_proc (void *trns_, struct ccase **c, casenumber
case_num UNUSED)
{
struct print_trns *trns = trns_;
bool eject = trns->eject;
- char encoded_space = legacy_from_native (trns->encoding, ' ');
+ char encoded_space = recode_byte (trns->encoding, LEGACY_NATIVE, ' ');
int record = 1;
struct prt_out_spec *spec;
@@ -518,7 +518,7 @@ flush_records (struct print_trns *trns, int target_record,
else
leader = '1';
}
- line[0] = legacy_from_native (trns->encoding, leader);
+ line[0] = recode_byte (trns->encoding, LEGACY_NATIVE, leader);
if (trns->writer == NULL)
tab_output_text (TAB_FIX, &line[1]);
diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c
index 59665be..cb15572 100644
--- a/src/libpspp/i18n.c
+++ b/src/libpspp/i18n.c
@@ -1,5 +1,5 @@
/* PSPP - a program for statistical analysis.
- Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -85,6 +85,20 @@ create_iconv (const char* tocode, const char* fromcode)
return converter->conv;
}
+/* Converts the single byte C from encoding FROM to TO, returning the first
+ byte of the result.
+
+ This function probably shouldn't be used at all, but some code still does
+ use it. */
+char
+recode_byte (const char *to, const char *from, char c)
+{
+ char x;
+ char *s = recode_string (to, from, &c, 1);
+ x = s[0];
+ free (s);
+ return x;
+}
/* Similar to recode_string_pool, but allocates the returned value on the heap
instead of in a pool. It is the caller's responsibility to free the
diff --git a/src/libpspp/i18n.h b/src/libpspp/i18n.h
index 37bd944..f1d4d4a 100644
--- a/src/libpspp/i18n.h
+++ b/src/libpspp/i18n.h
@@ -26,6 +26,8 @@ void i18n_init (void);
struct pool;
+char recode_byte (const char *to, const char *from, char);
+
char *recode_string (const char *to, const char *from,
const char *text, int len);
char *recode_string_pool (const char *to, const char *from,
--
1.7.2.3
- [formatting i18n 00/14] Fix i18n of formatted data, Ben Pfaff, 2011/02/19
- [formatting i18n 03/14] PRINT: Use UTF-8 encoding for output to the output subsystem., Ben Pfaff, 2011/02/19
- [formatting i18n 01/14] Use new Gnulib function dtoastr() to format short, accurate real numbers., Ben Pfaff, 2011/02/19
- [formatting i18n 04/14] i18n: New function recode_byte().,
Ben Pfaff <=
- [formatting i18n 10/14] format: Count prefix and suffix width in terms of display columns., Ben Pfaff, 2011/02/19
- [formatting i18n 08/14] data-out: Make each converter responsible for storing null terminator., Ben Pfaff, 2011/02/19
- [formatting i18n 12/14] pool: Support NULL pool argument to pool_alloc_unaligned()., Ben Pfaff, 2011/02/19
- [formatting i18n 14/14] data-out: Add test for non-ASCII custom currency formats., Ben Pfaff, 2011/02/19
- [formatting i18n 11/14] data-out: Reorganize output_Z() to be more easily understood., Ben Pfaff, 2011/02/19
- [formatting i18n 02/14] CROSSTABS: Eliminate redundant data copying., Ben Pfaff, 2011/02/19
- [formatting i18n 06/14] legacy-encoding: Remove., Ben Pfaff, 2011/02/19
- [formatting i18n 07/14] format: Increase abstraction of fmt_number_style., Ben Pfaff, 2011/02/19
- [formatting i18n 09/14] format: Create a new "struct fmt_affix" for prefix and suffix strings., Ben Pfaff, 2011/02/19
- [formatting i18n 05/14] i18n: Introduce C_ENCODING as replacement for LEGACY_NATIVE., Ben Pfaff, 2011/02/19