Issue with £ character when using MQLMySQL

To add comments, please log in or register
jlcash
12
jlcash  

Hi, I hope someone can help. I have been trying to use the MQLMySQL library to read and write to a MySQL database. The problem than I am encountering is related to my brokers use of (£) as symbol, suffixes  which for some reason causes issues when using this library. 

I have isolated this issue to a simple select statement that reads from a My SQL table named symbols. Table contains 3 columns, id, name & broker_name. The broker_name column contains symbol names such as "GPBCHF(£)". When using the library, the £ symbol is being replaced by either a ? (when printing the output) or a J (when viewing through the debugger). 

My read function from my data access object is shown below.

/*

      Read all symbols

   */

   public: void read(Symbol& symbols[])

   {

       string query;

       int i;

       int cursor;

       int numRows;

       int symbolId;

       string symbolName;

       string symbolBrokerName; 

       

       // executing SELECT statement

       query = "SELECT symbol_id, name, broker_name FROM symbol;";      

       

       cursor = MySqlCursorOpen(getDB(), query);

       

       if (cursor >= 0)

       {

         //How many rows? Resize array.

         numRows = MySqlCursorRows(cursor);

         ArrayResize(symbols, numRows);

         

         //Fetch data, create symbol objects and add to array

         for (i=0; i<numRows; i++)

         {

            if (MySqlCursorFetchRow(cursor))

            {

               

               symbolId = MySqlGetFieldAsInt(cursor, 0);

               symbolName = MySqlGetFieldAsString(cursor, 1);

               symbolBrokerName = MySqlGetFieldAsString(cursor, 2);

		Print ("ROW[",i,"]: id = ", symbolId, ", name = ", symbolName, ", brokerName = ", symbolBrokerName);

               Symbol symbol(symbolId, symbolName, symbolBrokerName);

               symbols[i] = symbol;

            }

          }

          MySqlCursorClose(cursor); // NEVER FORGET TO CLOSE CURSOR !!!

       }

       else

       {

         Print ("Cursor opening failed. Error: ", MySqlErrorDescription);

       }

   }


The first highlighted row above gets the brokerName from the cursor (3rd column). The second prints the output of all columns. The print statement outputs the following:

2018.05.31 21:29:17.787 Scratch AUDJPY(£),H1: ROW[2]: id = 3, name = GBPCHF, brokerName = GBPCHF(?)


When stepping through the debuggeer into the library, and setting a watch on result, line 213 (result = cMySqlGetRowField(pCursorID, pField);) sets result to GBPCHF(Ј).

Hope someone can help.

Eleni Anna Branou
Moderator
6643
Eleni Anna Branou  

Please use the </> button to insert your above code.


jlcash
12
jlcash  
Eleni Anna Branou:

Please use the </> button to insert your above code.


Done
To add comments, please log in or register