Table of Content
HAL Forum
function string ConvertStringFromCodePage (
string CurCodepage,string OriginalStr)
Description:
Converts a string, encoded with a specified codepage to unicode.
Parameters:
CurCodepage The current codepage of the specified string
OriginalStr String that will be converted to unicode
updating procedure ParseXRateReply_Russia(record RcVc RepSpec,Area a_reply)
begin
  LongInt lines,l;
  string 255 curncy,curncyname,units,rate,method,tstr,curstrkey;
  record BaseCurBlock BCb;
  record ERBlock ERb;
  Date ratedate;
  val ratev,unitsv,rateb1,rateb2;
  Area a_xmlreply;
  LongInt rerror,xmllen,headerl,read,i,cnt;
  xml xmlreply;

  BlockLoad(BCb);
  BlockLoad(ERb);
  read = GetAreaFromArea(a_reply,0,GetAreaLength(a_reply)-0,a_xmlreply);      
  
  xmlreply = ParseXMLArea(a_xmlreply);

  if (XmlNodeExists(xmlreply,"ValCurs")) then begin
    ratedate = DateFromString(XmlGetAttribute(xmlreply,"ValCurs","Date"),"DD.MM.YYYY");
    if (ratedate.year<=80) then begin
      ratedate.year = ratedate.year + 2000;
    end else begin
      if (ratedate.year<100) then begin
        ratedate.year = ratedate.year + 1900;
      end;
    end;
    if (ratedate==RepSpec.d1) then begin
      rateb1 = 1;
      rateb2 = 1;
      i = 0;
      curstrkey = "ValCurs/Valute[" & i & "]";
      while (XmlNodeExists(xmlreply,curstrkey)) begin
        curncy = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/CharCode"));
        curncyname = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/Name"));
        rate = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/Value"));
        units = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/Nominal"));
        
        unitsv = StringToValue(units,M4Rate,"",",");
        ratev = StringToValue(rate,M4Rate,"",",");

        if (curncy==BCb.BaseCur1) then begin
          rateb1 = ratev;
        end;
        if (curncy==BCb.BaseCur2) then begin
          rateb2 = ratev;
        end;        
        i = i+1;
        curstrkey = "ValCurs/Valute[" & i & "]";
      end;

      i = 0;
      curstrkey = "ValCurs/Valute[" & i & "]";
      while (XmlNodeExists(xmlreply,curstrkey)) begin
        curncy = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/CharCode"));
        curncyname = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/Name"));
        rate = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/Value"));
        units = ConvertStringFromCodePage("WINDOWS-1251",XmlGet(xmlreply,curstrkey & "/Nominal"));
        
        unitsv = StringToValue(units,M4Rate,"",",");
        ratev = StringToValue(rate,M4Rate,"",",");
        ratev = ratev/rateb1;
        AddCurencyRate(RepSpec,BCb,ERb,curncy,curncyname,ratev,rateb1/rateb2,unitsv,ratedate);

        i = i+1;
        curstrkey = "ValCurs/Valute[" & i & "]";
      end;
    end;
  end;

  return;
end;
Related topics:
««