Answer the question
In order to leave comments, you need to log in
How to convert string from Windows 1251 to UCS-2 (algorithm)?
There is a certain software product with a layer of business code in a certain language with a very flexible syntax, it looks like pascal, while it calmly eats the Pascal syntax next to java and plus, apparently it was made so that "anyone could write". It is necessary to change the text encoding, but so that the result remains in string as it is, is there any algorithm that could be taken as a basis?
ps There are no language-specific functions in this "semi-language", although some analogues with Pascal-like syntax are present.
You need to change the encoding of the string from windows 1251 to UCS-2 or UTF-16.
You need to re-encode to send it to the smpp provider, it eats Cyrillic only in UCS-2 or UTF-16.
An example of the code that this environment eats is a code fragment that works and compiles normally despite the difference in syntax.
except
sResult := '';
end;
sSource := ReplaceStr(sSource, '%h' + IntToStr(k),sResult);
end;
end;
finally
if (lFldHndl <> nil) then FreeObject(lFldHndl);
if (lFldName <> nil) then FreeObject(lFldName);
if (oDL <> nil) then FreeObject(oDL);
end;
if bTransliteSMS then
Result = TranslateRus2Lat(sSource)
else Result := sSource;
Answer the question
In order to leave comments, you need to log in
Delphi has a special type, WideString, which corresponds to a pointer to a UTF-16 string.
For translation, the StringToWideChar function is used.
There is also a WinApi function MultiByteToWideChar .
there is also a TEncoding class, is this support really available in this product
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question