現在、この作業は、ロシア語のテキストの文字列をラテン語のアルファベットの文字変換に変換する文字変換関数の作成によって補完されています。さらに、文字列にラテン文字が含まれている場合、それらは翻訳されません。つまり、関数には、文字と単語の混合文字列を引数として渡すことができます。
文字の変換は、GOST 7.79-2000(システムB)に従って実行されます。末尾の「LE」が「IE」として、「OY」が「IJ」として文字変換されることを除いて、名前の文字変換に関する特別な規則は考慮されません。
以下は完全な機能コードです。
# Function Translite of Russian characters for sending in Telegram
# by Sertik 16/09/2020
# usage [$FuncTransliteToTele " String .,!+"]
:global FuncTransliteToTele do={
:global string; :set $string $1;
# table of the codes of Russian letters Translite
:local rsimv [:toarray {""="A"; ""="B"; ""="V"; ""="G"; ""="D"; ""="E"; ""="ZH"; ""="Z"; ""="I"; ""="J"; ""="K"; ""="L"; ""="M"; ""="N"; ""="O"; ""="P"; ""="R"; ""="S"; ""="T"; ""="U"; ""="F"; ""="KH"; ""="C"; ""="CH"; ""="SH"; ""="SCH"; ""="``"; ""="Y`"; ""="`"; ""="E`"; ""="JU"; ""="YA"; ""="a"; ""="b"; ""="v"; ""="g"; ""="d"; ""="e"; ""="zh"; ""="z"; ""="i"; ""="j"; ""="k"; ""="l"; ""="m"; ""="n"; ""="o"; ""="p"; ""="r"; ""="s"; ""="t"; ""="u"; ""="f"; ""="kh"; ""="c"; ""="ch"; ""="sh"; ""="sch"; ""="``"; ""="y`"; ""="`"; ""="e`"; ""="ju"; ""="ya"; ""="Yo"; ""="yo"; "№"="#"}]
# encoding of the symbols and ssembly line
:local StrTele ""; :local code "";
:for i from=0 to=([:len $string]-1) do={:local keys [:pick $string $i (1+$i)];
:local key ($rsimv->$keys); if ([:len $key]!=0) do={:set $code ($rsimv->$keys);} else={:set $code $keys};
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "I"; :set $i ($i+1)}
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "i"; :set $i ($i+1)}
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "I"; :set $i ($i+1)}
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "i"; :set $i ($i+1)}
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "I"; :set $i ($i+1)}
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "i"; :set $i ($i+1)}
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "i"; :set $i ($i+1)}
:if (($keys="") and ([:pick $string ($i+1) (2+$i)]="")) do={:set $code "I"; :set $i ($i+1)}
:set $StrTele ("$StrTele"."$code")}
:set $string $StrTele
:return $string;
}
仕組みの例を次に示します。
:local string [$FuncTransliteToTele " ! - Russian alfabit Telegramm. "]
:log warning $string
ログ 出力:Privet ot Mikrotik!Rabotaet funksiya-konverter Russian-alfabit dliyaTelegramm。ザヤックビリー。
ユーザーは、自分が使用する標準の文字変換テーブルを修正できます。誰かのお役に立てば幸いです。これで、ここからのコンバーター機能を使用してUTF-8コードに変換することと、文字変換によって、ロシアのメッセージをTelegramに送信することに落ち着くことができます。