Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1017

 
Money_Maker:
Could you please tell me the data<td colspan="8\" class=\"theDay\">\u0421\u0440\u0435\u0434\u0430, \u0410\u043f\u0440\u0435\u043b\u044c 20, 2016</td>\n UTF-8 format

I understand correctly, that russian needs to be converted to ANSI, i.e. to CP_ACP?

I do it like this string ttt =CharArrayToString(RESULT,0,CP_ACP); Nothing changes, just the data is stored in the string variable
Saving into a file under CP_ACP does not work either.
I am doing something wrong . The online decoder translates correctly. the result is: heDay\">Wednesday, April 20, 2016<\/td>\n
The question is how to do it in MQL?
How do you know - write. I have a similar problem.
 
Money_Maker:
Could you please tell me the data<td colspan="8\" class=\"theDay\">\u0421\u0440\u0435\u0434\u0430, \u0410\u043f\u0440\u0435\u043b\u044c 20, 2016</td>\n UTF-8 format

I understand correctly, that russian needs to be converted to ANSI, i.e. to CP_ACP?

I do it like this string ttt =CharArrayToString(RESULT,0,CP_ACP); Nothing changes, just the data is stored in the string variable
Saving into a file under CP_ACP does not work either.
I am doing something wrong . The output is heDay\">Wednesday, April 20, 2016<\/td>\n (I also used uurlencoded post filter when converting from UTF-8)
QUESTION how to do it in MQL?
https://forum.mql4.com/ru/67441
 
eevviill:
https://forum.mql4.com/ru/67441
Print(CharArrayToString(RESULT));
no recoding takes place... ( I already tried that ... I think I found something similar ... https://forum.mql4.com/ru/18476

#import "kernel32.dll"
   int WideCharToMultiByte(int CodePage, int dwFlags, int &lpWideCharStr[], int cchWideChar, string lpMultiByteStr, int cbMultiByte, 
                           int lpDefaultChar, int lpUsedDefaultChar);
#import

It hasn't worked yet... but it seems to be the right one, or is it wrong?
 
Can you please tell me how to convert the data as shown in the picture (cadabras into russian letters)? Where to dig in which direction(?


 
Money_Maker:
Can you please tell me how to convert the data as shown in the picture (cadabras into russian letters)? Where to dig in which direction(?



If I am not mistaken, it is base64, it can be programmatically recoded only in PHP, or write your own function in MQ
 
Thank you, I've already thought of different options from
1 download taking into account the encoding
2 download page after request in browser, it displays fine
3 different functions converted from WinDLL or C++
4 now come that I will pick up for each letter a code and use it to decode (i.e. their own function)


OK, how do I write this "\u0430" in MQL code?

I get a warning 'u' - unrecognized character escape sequence

 
Money_Maker:
Thanks, already thought of different options from
1 download taking into account the encoding
2 download page after query in browser, it will display fine.
3 different functions to convert from WinDLL or C++
4 now I have come to pick up for each letter a code and use it to decode (i.e. own function)


OK, how do I write this "\u0430" in MQL code?

I get a 'u' - unrecognized character escape sequence warning

Here in PHP, following her principle of doing it in MQ

function conv($str)
{
$uot = '';
$unicodePoints = array( '\u0410','\u0411','\u0412','\u0413',
'\u0414','\u0415','\u0416','\u0417',
'\u0418','\u0419','\u041A','\u041B',
'\u041C','\u041D','\u041E','\u041F',
'\u0420','\u0421','\u0422','\u0423',
'\u0424','\u0425','\u0426','\u0427',
'\u0428','\u0429','\u042A','\u042B',
'\u042C','\u042D','\u042E','\u042F',
'\u0430','\u0431','\u0432','\u0433',
'\u0434','\u0435','\u0436','\u0437',
'\u0438','\u0439','\u043A','\u043B',
'\u043C','\u043D','\u043E','\u043F',
'\u0440','\u0441','\u0442','\u0443',
'\u0444','\u0445','\u0446','\u0447',
'\u0448','\u0449','\u044A','\u044B',
'\u044C','\u044D','\u044E','\u044F');
$hexView = array(   'd090','d091','d092','d093',
'd094','d095','d096','d097',
'd098','d099','d09a','d09b',
'd09c','d09d','d09e','d09f',
'd0a0','d0a1','d0a2','d0a3',
'd0a4','d0a5','d0a6','d0a7',
'd0a8','d0a9','d0aa','d0ab',
'd0ac','d0ad','d0ae','d0af',
'd0b0','d0b1','d0b2','d0b3',
'd0b4','d0b5','d0b6','d0b7',
'd0b8','d0b9','d0ba','d0bb',
'd0bc','d0bd','d0be','d0bf',
'd180','d181','d182','d183',
'd184','d185','d186','d187',
'd188','d189','d18a','d18b',
'd18c','d18d','d18e','d18f' );
for($i=0; $i < strlen( $str ); $i++)
{
if(bin2hex($str{$i}) >= 'd0' && bin2hex($str{$i}) <= 'd1')
{
$uot .= bin2hex($str{$i}).bin2hex($str{$i+1});
$i++;
}
elseif(bin2hex($str{$i}) <= '7e')
{
$uot .= '\u00'.bin2hex($str{$i});
}
else $uot .= htmlentities($str{$i},ENT_QUOTES,'UTF-8');
}
return str_replace($hexView,$unicodePoints, $uot);
}

The idea is that you break down the string into characters and do a character-by-character replacement with the right character when it matches the array.

 
Trader76:

Here in PHP, following her principle of doing it in MQ

The idea is that you break the string into characters and do a character-by-character replacement with the correct character when it matches the array.

thank you so much it will be faster, I also so the principle decided to "lippy" special thanks for the character codes now they will not have to search for them.
 
Money_Maker:
Thank you very much it will be faster, that's why I also decided to "lick" the principle special thanks for the character codes now I won't have to search for them.

StringGetChar()

StringGetChar()

Or is it wrong?

 
Money_Maker:
Thank you very much this will be faster, that's why I also decided to "lippy" special thanks for the character codes now I won't have to search for them.

I wrote to replace short names for characters, break lines into letters, and do the replacement.

string sub_symb[];
ushort u_sep=StringGetCharacter(" ",0);
string SymbolArr[]={
//-------------------- в конце ставить запятую и писать через пробел
// СЕЛЬХОЗ.ПРОДУКЦИЯ
 "Молоко DC",
 "Корм GF",
 "Свинина HE",
 "Рогатый_скот LE",
 "Кукуруза ZC",
 "Соевое_масло ZL",
 "Соевая_мука ZM",
 "Соевые_бобы ZS",
 "Пшеница ZW",
// ЭНЕРГИЯ
 "#BRENT CL",
 "Мазут HO",
 "Газ NG",
 "Газ(мини) QG",
 "Нефть_WTI_(мини) QM",
 "Бензин RB",
// ИНДЕКСЫ
 "S&P_(мини) ES",
 "NASDAQ_(мини) NQ",
 "S&P_500 SP",
 "#DJI30 YM",
 "#DAX30 FDAX",
// МЕТАЛЛЫ
 "Золото GC",
 "Медь HG",
 "Палладий PA",
 "Платина PL",
 "Серебро SI",
 "IndexUSD DX",

//+---------------------------------------------------------------------------------------------+
};

string SubSymbols(string CurSymb)
 {
 for(int i=0; i<ArraySize(SymbolArr); i++)
  {
   StringSplit(SymbolArr[i],u_sep,sub_symb);
   if(CurSymb==sub_symb[0])
    {
     return(sub_symb[1]);
    }
  }
//-
 return(_Symbol);
 }