Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quickfix/n how to change the encoding from iso-8859-1 to windows-1251 #739

Open
githubniko opened this issue Aug 24, 2022 · 7 comments
Open

Comments

@githubniko
Copy link

Hello.
The server transmits FIX messages in windows-1251 encoding. QuickFix writes data to a log file in iso-8859-1. Is it possible to change the encoding without recompiling quickfix/n ?

@mgatny
Copy link
Member

mgatny commented Aug 24, 2022

Are you using an older version of qf/n?

I think we very explicity transmit in iso-8859-1 (latin1) which is the protocol standard:

~/dev/quickfixn/QuickFIXn$ cat CharEncoding.cs; grep -A5 " Send(" SocketReader.cs SocketInitiatorThread.cs 
namespace QuickFix
{
    public static class CharEncoding
    {
        public static System.Text.Encoding DefaultEncoding;

        static CharEncoding()
        {
            DefaultEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
        }
    }
}
SocketReader.cs:        public int Send(string data)
SocketReader.cs-        {
SocketReader.cs-            byte[] rawData = CharEncoding.DefaultEncoding.GetBytes(data);
SocketReader.cs-            stream_.Write(rawData, 0, rawData.Length);
SocketReader.cs-            return rawData.Length;
SocketReader.cs-        }
--
SocketInitiatorThread.cs:        public bool Send(string data)
SocketInitiatorThread.cs-        {
SocketInitiatorThread.cs-            byte[] rawData = CharEncoding.DefaultEncoding.GetBytes(data);
SocketInitiatorThread.cs-            stream_.Write(rawData, 0, rawData.Length);
SocketInitiatorThread.cs-            return true;
SocketInitiatorThread.cs-        }

@githubniko
Copy link
Author

githubniko commented Sep 4, 2022

I want the encoding to be taken out to the settings. This will make quick fix more flexible.

"ISO-8859-1" is a standard for English-speaking people. My broker uses win1251 by default and I get a crooked text display and then I have to recode the iso-8859-1 - >win1251, which consumes computing resources.

Now I have edited win1251 encoding in the Char Encoding.cs file and everything has worked for me. Example:

public static class CharEncoding
    {
        public static System.Text.Encoding Default Encoding;

        static Char Encoding()
        {
            ////Default Encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
            Default Encoding = System.Text.Encoding.GetEncoding(1251);
        }
    }

image

  1. Default Encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
  2. (right) Default Encoding = System.Text.Encoding.GetEncoding(1251);

@mgatny
Copy link
Member

mgatny commented Sep 7, 2022

I wouldn't be opposed to exposing it as a SessionSetting. Although the FIX Protocol standard requires latin1, many firms (including very large ones) obviously do not adhere to it.

@jded76
Copy link

jded76 commented Mar 10, 2023

We faced the same problem with the encoding. Is there any chance to implement this?

There was a commit (e7d59ce)) that implemented that, but this commit (a75fc7c) reverted back.

Thank you

@jded76
Copy link

jded76 commented Mar 17, 2023

Can I do something to help on this?
I think it's an easy fix and without any danger (if you don't change it, it will work as it is right now).

@jded76
Copy link

jded76 commented Mar 17, 2023

I said an easy fix because I have in mind that I don't need it per session.
We can have a similar approach that QuickFixJ has (see here).
A static SetEncoding that we can call one time at the beginning.
So the fix will be easy enough.

@jded76
Copy link

jded76 commented Mar 1, 2024

@gbirchmeier I saw that there is activity lately with a lot of changes.
Any change to take a look in this too (see my previous comments)?

We have forked and build our own version just to support a different encoding, so we are stuck without updates.

Thank you

P.S. QuickfixJ current implementation here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants