Files
oc-server3/htdocs/lib2/charset.inc.php
following f5565a918c ported search.php & tools to lib2, and ...
- fixed logentry sorting for logs with identical date
- fixed ä etc. display in short descriptions on search results page
- try to select a matching language for the short descriptions
- added some translations
- hide download and map links if no search results (updates #235)
- nicer display of selectlocid page
- use site-dependent urls in GPX, LOC, TXT and KML
- unified XML encoding, now all done via two functions in lib2/util.inc.php (updates #121)
- some preventive XML encoding adjustments in GPX
- removed XML encoding in LOC CDATA section
- improved charset conversion for OVL and OV2 output
- some optimizations
- discarded lots of obsolete code
- disabled debug mode force_compile in OcSmarty class (performance)
2013-07-13 12:38:57 +02:00

74 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/****************************************************************************
For license information see doc/license.txt
Unicode Reminder メモ
charset related functions
****************************************************************************/
// replacement table for Unicode 0x100 to 0x1FF
$utf_xlatin = "A a A a A a C c C c C c C c D d D d E e E e E e E e E e G g G g " .
"G g G g H h H h I i I i I i I i I i IJijJ j K k K L l L l L l L " .
"l L l N n N n N n n n n O o O o Ö ö OEoeR r R r R r S s S s S s " .
"S s T t T t T t U u U u U u U u Ü ü U u W w Y y Y Z z Z z Z z ";
// replacement table for Unicode 0x2000 to 0x203F
$utf_punct = " ------|_'','\"\"\"\"++*>.... %%´\"\"`\"\"^<> !?- ";
// convert utf-8 string to iso-8859-1 and use replacemend characters if possible
function utf8ToIso88591($s)
{
global $utf_xlatin, $utf_punct;
$pos = 0;
$result = "";
while ($pos < strlen($s))
{
$c1 = ord($s[$pos++]);
if ($c1 < 0xC0)
$result .= chr($c1);
else if ($pos < strlen($s))
{
$c2 = ord($s[$pos++]);
if ($c1 < 0xE0)
{
$code = 0x40 * ($c1 & 0x1F) + ($c2 & 0x3F);
if ($code < 0x100)
$result .= chr($code);
else if ($code < 0x200)
{
$result .= $utf_xlatin[2*($code - 0x100)];
if ($utf_xlatin[2*($code - 0x100) + 1] != ' ')
$result .= $utf_xlatin[2*($code - 0x100) + 1];
}
else
$result .= "?";
}
else if ($pos < strlen($s))
{
$c3 = ord($s[$pos++]);
$code = 0x1000 * ($c1 & 0x0F) + 0x40 * ($c2 & 0x3F) + ($c3 & 0x3F);
switch ($code)
{
case 0x2026 : $result .= "..."; break;
case 0x2025 : $result .= ".."; break;
case 0x20AC : $result .= "Euro"; break;
default:
if ($code >= 0x2000 && $code <= 0x203F)
$result .= $utf_punct[$code - 0x2000];
else
$result .= "?";
}
}
}
}
return $result;
}
?>