if (!function_exists("yandex_text2xml"))
{
 function yandex_text2xml($text, $bHSC = false, $bDblQuote = false)
 {
  global $APPLICATION;

  $bHSC = (true == $bHSC ? true : false);
  $bDblQuote = (true == $bDblQuote ? true: false);

  if ($bHSC)
  {
   $text = htmlspecialcharsbx($text);
   if ($bDblQuote)
    $text = str_replace('"', '"', $text);
  }
  $text = preg_replace("/[\x1-\x8\xB-\xC\xE-\x1F]/", "", $text);
  $text = str_replace("'", "'", $text);
  $text = $APPLICATION->ConvertCharset($text, LANG_CHARSET, 'windows-1251');
  return $text;
 }
}