ICU-1220 support IDs and compound IDs, but also complex rules in the -x

argument.

X-SVN-Rev: 7688
This commit is contained in:
Yves Arrouye 2002-02-16 07:43:26 +00:00
parent 6ed0e847b6
commit 161c2863a7
3 changed files with 28 additions and 12 deletions

View File

@ -1,6 +1,6 @@
// -*- Coding: utf-8; -*- [all uconv resource files]
// Copyright (c) 2000 IBM, Inc. and Others.
// $Revision: 1.21 $
// $Revision: 1.22 $
//
// Root translation file for uconv messages.
// So you want to translate this file??? Great!
@ -67,7 +67,7 @@ root
cantOpenFromCodeset { "Couldn''t open from encoding {0}: {1}\n" } // 0:set, 1: err
cantOpenToCodeset { "Couldn''t open to encoding {0}: {1}\n" } // 0: set, 1: err
cantOpenTranslit { "Couldn''t open transliteror {0}: {1}\n" } // 0: set, 1: err
cantCreateTranslit { "Couldn''t create transliteror {0}: {1}\n" } // 0: set, 1: err
cantSetCallback { "Couldn''t set transcoding callback: {0}\n" } // 0: err

View File

@ -37,7 +37,7 @@
.BI "\-\-canon"
]
[
.BI "\-x" " transliterator
.BI "\-x" " transliteration
]
[
.BI "\-\-to\-callback" " callback"
@ -90,10 +90,16 @@ such characters in the input. Other callbacks offer a useful visual
representation of the invalid data.
.PP
.B uconv
can also run the transcoding through a specified
.IR transliterator ,
can also run the specified
.IR transliteration
on the transcoded data,
in which case transliteration will happen as an intermediate step,
after the data have been transcoded to Unicode.
The
.I transliteration
can be either a list of semicolon-separated transliterator names,
or an arbitrary complex set of rules in the ICU transliteration
rules format.
.SH OPTIONS
.TP
.BR "\-h\fP, \fB\-?\fP, \fB\-\-help"
@ -137,12 +143,12 @@ If used with
.BR "\-L\fP, \fB\-\-list\-transliterators" ,
print only one transliterator name per line.
.TP
.BI "\-x" " transliterator"
Run the transcoded Unicode data through the given
.IR transliterator
.BI "\-x" " transliteration"
Run the given
.IR transliteration
on the transcoded Unicode data,
and use the transliterated data as input for the transcoding to
the the destination encoding. Compound transliterators can be
created by separating individual names with a semicolon.
the the destination encoding.
.TP
.BI "\-\-to\-callback" " callback"
Use

View File

@ -26,6 +26,7 @@
#include <unicode/translit.h>
#include "cmemory.h"
#include "cstring.h"
#include "unicode/uwmsg.h"
@ -424,12 +425,21 @@ static UBool convertFile(const char *pname,
// Create transliterator as needed.
if (translit != NULL && *translit) {
UParseError parse;
UnicodeString str(translit);
t = Transliterator::createInstance(str, UTRANS_FORWARD, err);
/* Create from rules or by ID as needed. */
if (uprv_strchr(translit, ':') || uprv_strchr(translit, '>') || uprv_strchr(translit, '<') || uprv_strchr(translit, '>')) {
t = Transliterator::createFromRules("Uconv", str, UTRANS_FORWARD, parse, err);
} else {
t = Transliterator::createInstance(translit, UTRANS_FORWARD, err);
}
if (U_FAILURE(err)) {
str.append((UChar32) 0);
initMsg(pname);
u_wmsg("cantOpenTranslit", str.getBuffer(),
u_wmsg("cantCreateTranslit", str.getBuffer(),
u_wmsg_errorName(err));
if (t) {
delete t;