ePages 6.17.15 - DE_EPAGES/Core/API/Unicode.pm

Package DE_EPAGES::Core::API::Unicode

Functions to convert Unicode strings to valid URL or file names

@EXPORT_OK
Unicode2Alias
Unicode2Filename
Unicode2Path
Unicode2DirectoryName
CharMapping
OrdMapping

Functions

CharMapping
OrdMapping
Unicode2Alias
Unicode2DirectoryName
Unicode2Filename
Unicode2Path

CharMapping

Returns a replacement string for characters that are not allowed in URLs or file names.

Syntax
$ReplaceString = CharMapping($Char)
Example
print CharMapping('ö'); # oe
Input
$Char (string)
single character
Return
$ReplaceString (string)
replacement string

OrdMapping

Returns a replacement string for selected Unicode characters.

Syntax
$ReplaceString = OrdMapping($CharCode)
Example
print OrdMapping(223); # ss
Input
$CharCode (int)
Unicode number of a character
Return
$ReplaceString (string)
replacement string

Unicode2Alias

Returns an iso1 charset string, which can be used as Alias for objects. Spaces will be replaced by '_' and complex chars to simples.

Syntax
$Alias = Unicode2Alias($UnicodeString)
$Alias = Unicode2Alias($UnicodeString, $AllowedChars)
Example
'AAAAAA' eq Unicode2Alias('ÀÁÂÃÄÅ')
'Viele_Koche' eq Unicode2Alias('Viele Köche')
'file_nametxt' eq Unicode2Alias('file name.txt')
'file_name.txt' eq Unicode2Alias('file name.txt', '.')
Input
$UnicodeString (String)
utf8 string
$AllowedChars (String)
utf8 string, containing allowed chars
Return
$Alias (String)
iso1 string

Unicode2DirectoryName

Returns a filtered string, which can be used as directory name. Spaces will be replaced by '_', complex chars to simples and all unknown characters to their ordinal number, i.e. '{' is replaced by '_123_'.

Syntax
$CleanString = Unicode2DirectoryName($UnicodeString)
$CleanString = Unicode2DirectoryName($UnicodeString, $AllowedChars)
Example
'/asd/Hundchenolgemaldejpg' eq Unicode2DirectoryName('/asd/!#Hündchenölgemälde.jpg')
'/a_s_d/!Hundchen_Olgemalde-EEEII_123__125_b.sozdavat' eq
Unicode2DirectoryName('/a_s_d/!#Hündchen Ölgemälde-ÉÊËÌÍ#{}(b+).создавать', '!.')
Input
$UnicodeString (String)
utf8 string
$AllowedChars (String)
utf8 string, containing allowed chars
Return
$CleanString (String)
filtered string

Unicode2Filename

Returns a filtered string, which can be used as file name. Spaces will be replaced by '_', complex chars to simples and all unknown characters to their ordinal number, i.e. '{' is replaced by '_123_'.

Syntax
$CleanString = Unicode2Filename($UnicodeString)
$CleanString = Unicode2Filename($UnicodeString, $AllowedChars)
Example
'asdHundchenolgemalde.jpg' eq Unicode2Filename('/asd/!#Hündchenölgemälde.jpg')
'a_s_d!Hundchen_Olgemalde-EEEII_123__125_b.sozdavat' eq
Unicode2Filename('/a_s_d/!#Hündchen Ölgemälde-ÉÊËÌÍ#{}(b+).создавать', '!')
Input
$UnicodeString (String)
utf8 string
$AllowedChars (String)
utf8 string, containing allowed chars
Return
$CleanString (String)
filtered string

Unicode2Path

Returns a filtered string, which can be used as directory name. Spaces will be replaced by '_', complex chars to simples and all unknown haracters to their ordinal number, i.e. '{' is replaced by '_123_'.

Syntax
$CleanString = Unicode2Path($UnicodeString)
$CleanString = Unicode2Directory($UnicodeString, $AllowedChars)
Example
'/asd/Hundchenolgemaldejpg' eq Unicode2Directory('/asd/!#Hündchenölgemälde.jpg')
'/a_s_d/!Hundchen_Olgemalde-EEEII_123__125_b.sozdavat' eq
Unicode2Directory('/a_s_d/!#Hündchen Ölgemälde-ÉÊËÌÍ#{}(b+).создавать', '!.')
Input
$UnicodeString (String)
utf8 string
$AllowedChars (String)
utf8 string, containing allowed chars
Return
$CleanString (String)
filtered string