View | Details | Raw Unified | Return to bug 5682
Collapse All | Expand All

(-)a/C4/Charset.pm (-10 / +11 lines)
Lines 33-38 BEGIN { Link Here
33
    require Exporter;
33
    require Exporter;
34
    @ISA    = qw(Exporter);
34
    @ISA    = qw(Exporter);
35
    @EXPORT = qw(
35
    @EXPORT = qw(
36
        NormalizeString
36
        IsStringUTF8ish
37
        IsStringUTF8ish
37
        MarcToUTF8Record
38
        MarcToUTF8Record
38
        SetUTF8Flag
39
        SetUTF8Flag
Lines 148-174 sub SetUTF8Flag{ Link Here
148
149
149
=head2 NormalizeString
150
=head2 NormalizeString
150
151
151
    my $normalized_string=NormalizeString($string);
152
    my $normalized_string=NormalizeString($string,$nfd,$transform);
152
153
153
Given a string
154
Given a string
154
155
nfd : If you want to set NFD and not NFC
155
nfc : If you want to set NFC and not NFD
156
transform : If you expect all the signs to be removed
156
transform : If you expect all the signs to be removed
157
157
Sets the PERL UTF8 Flag on your initial data if need be
158
Sets the PERL UTF8 Flag on your initial data if need be
158
and applies cleaning if required 
159
and applies cleaning if required
159
160
160
Returns a utf8 NFD normalized string
161
Returns a utf8 NFC normalized string
161
162
162
Sample code :
163
Sample code :
163
    my $string=NormalizeString ("l'ornithoptère");
164
   my $string=NormalizeString ("l'ornithoptère");
164
    #results into ornithoptère in NFD form and sets UTF8 Flag
165
   #results into ornithoptère in NFC form and sets UTF8 Flag
165
166
166
=cut
167
=cut
167
168
169
168
sub NormalizeString{
170
sub NormalizeString{
169
	my ($string,$nfc,$transform)=@_;
171
	my ($string,$nfd,$transform)=@_;
170
	utf8::decode($string) unless (utf8::is_utf8($string));
172
	utf8::decode($string) unless (utf8::is_utf8($string));
171
	if ($nfc){
173
	if ($nfd){
172
		$string= NFD($string);
174
		$string= NFD($string);
173
	}
175
	}
174
	else {
176
	else {
175
- 

Return to bug 5682