Skip to content

getColumn and getExtendedSql returning blank when string is over around 120 characters #4

@beerb0x

Description

@beerb0x

I am using build 1280 of mt4 and I ran into this wierd problem, im not sure if its just me or it will effect others but i wanted to post my (dodgy) fix if anyone else runs into it. Any time i used getColumn on a table field that was larger than around 120characters or used getExtendedSql and the query was over 120 chars long i was getting a blank return value. Im no c programer but i dug around and worked out a dodgy fix just to get me out, I made a single line addition to StringFromUtf8Pointer in Common.mqh after the second call to MultiByteToWideChar.

string StringFromUtf8Pointer(intptr_t psz,int len)
  {
   if(len < 0) return NULL;
   string res;
   int required=MultiByteToWideChar(CP_UTF8,0,psz,len,res,0);
   StringInit(res,required);
   int resLength = MultiByteToWideChar(CP_UTF8,0,psz,len,res,required);
   res = StringFormat("%s",res);
   if(resLength != required)
     {
      return NULL;
     }
   else
     {
      return res;
     }
  }

Im no C programer and i have very little idea of what im doing so im unsure what caused this (maybe the copied string in memory doesnt quite jazz with mt4 perfectly) but my hack seems to have fixed it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions