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

Russian text in wb.exe #251

Open
ghost opened this issue May 6, 2018 · 7 comments
Open

Russian text in wb.exe #251

ghost opened this issue May 6, 2018 · 7 comments

Comments

@ghost
Copy link

ghost commented May 6, 2018

Hi levak, add to file "wb.c" line "setlocale(0,"");"
After "int main(DTP, char *argv[])".

You should get:

/**
 * WarfaceBot, a blind XMPP client for Warface (FPS)
 * Copyright (C) 2015-2017 Levak Borok <[email protected]>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */


#include <wb_log.h>
#include <wb_cvar.h>
#include <wb_option.h>
#include <wb_stream.h>
#include <wb_xmpp.h>
#include <wb_xmpp_wf.h>
#include <wb_session.h>
#include <wb_threads.h>
#include <wb_lang.h>
#include <wb_tools.h>

int main(int argc, char *argv[])
{   
    setlocale(0,"");
    const char *exe_path = argv[0];

    cvar_init();

    cvar_parse_file("wb.cfg");

    if (cvar.g_language != NULL)
    {
        char *path;

        FORMAT(path, "cfg/lang/%s.cfg", cvar.g_language);
        cvar_parse_file(path);
        free(path);
    }

    char *token = NULL;
    char *online_id = NULL;
    char *cmdline = NULL;

    option_parse(argc, argv, &token, &online_id, &cmdline);

    /* Start of -- Legal Notices */

    if (isatty(STDOUT_FILENO))
    {
        xprintf(
            "\nWarfacebot Copyright (C) 2015-2017 Levak Borok\n"
            "This program comes with ABSOLUTELY NO WARRANTY.\n"
            "This is free software, and you are welcome to redistribute it\n"
            "under certain conditions; see AGPLv3 Terms for details.\n");
    }

    /* End of -- Legal Notices */

    idh_init();

    XMPP_REGISTER_QUERY_HDLR();
    XMPP_WF_REGISTER_QUERY_HDLR();

    int wfs = stream_connect(cvar.online_server,
                             cvar.online_server_port);

    if (wfs > 0)
    {
        session_init(wfs, online_id);

        threads_init();

        xmpp_connect(token, online_id);

        threads_run(exe_path, cmdline);

        threads_quit();

        xmpp_close();

        session_free();
    }

    free(token);
    free(online_id);
    free(cmdline);

    xprintf("%s", LANG(wb_closing));

    cvar_free();

    return 0;
}

This gives Russian input to the console (wb.exe).
Sorry about my English.

@Levak
Copy link
Owner

Levak commented May 6, 2018

Thanks for the input. 👍
Will take a look later.

@Levak
Copy link
Owner

Levak commented May 8, 2018

Hi,

This single line doesn't seem to solve anything on my side, it actually makes things worse:

Канал: 
ID профил�: 
�ик: 
Кредиты: 0
Зашел на канал 
Опыт: 
Ранг РМ: 0
Варбак�ы: 
Короны: 
Кредиты: 0
Разблокированные предметы: 
Уведомление:  
СМD#

And still can't type anything.
In order to test this, I installed RU locale on my Win10.

  • MSYS with CP850 doesn't display RU chars properly (like above) and typing with RU keyboard returns ?.
  • wb with CP65001 and setlocale(0, "") doesn't display RU chars properly (like above) and typing with RU keyboard doesn't accept any input.
  • wb with CP65001 and setlocale(0, NULL) does display RU chars properly but typing with RU keyboard doesn't accept any input.
  • wb with CP850 and any of the setlocale() doesn't display RU chars properly and typing with RU keyboard return ?

I tried to give to setlocale() things like ru-RU or ru_RU, .ACP, .65001, .1251, .850, none of them led to positive results.

How are you compiling wb? With MINGW or Cygwin?

@ghost
Copy link
Author

ghost commented May 8, 2018

CygWin.
With this function I got the following(I didn't use 1251 or 65001):
v

@ghost
Copy link
Author

ghost commented May 8, 2018

Levak, try -
setlocale(0, "ru_RU.UTF-8");

Okay?
Waiting to accomplish your goal.

@Levak
Copy link
Owner

Levak commented May 8, 2018

CygWin

How are you launching warfacebot? Via Cygwin terminal or using wb_launcher.hta?

Levak, try -
setlocale(0, "ru_RU.UTF-8");

In Cygwin it indeed fixes the input feedback, but cygwin is not the one used to compile public releases. It's Mingw. And with Mingw, no input is possible with RU keyboard.

On Cygwin I also have some sort of bug from the readline, when I press backspace it inputs a space, when I press Delete it inputs a ~. Trying to update Cygwin at the moment.

@ghost
Copy link
Author

ghost commented May 8, 2018

I add the line "setlocale(0, "ru_RU.UTF-8");" to the file "wb.c". Create a wb.exe, login via hta-launcher (without 1251), and I have Russian text with Russian input. Create a wb.exe using CYGWIN.

Perhaps you are not working Russian language due to the fact that you have Russian is not present? I have and have my friend the text Russian and core, too,. English also works.

@Levak
Copy link
Owner

Levak commented May 8, 2018

Again.
Cygwin works fine with RU input with your fix (setlocale(0, NULL)) but, not with Mingw.
In Mingw there is 0 input, and that's the target for public releases.

Same, you might also have colors using Cygwin, while in Mingw there is none.

I'll let this issue open til I figure out what to do exactly with public releases, as publishing Cygwin packages is a no-go for me.

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

No branches or pull requests

1 participant