B4J Question unicode problem with jshell

behnam_tr

Active Member
Licensed User
Longtime User
I receive a string from C# with jshell, which contains Arabic and Farsi characters, but instead of the original text, only the symbol ??? I receive.
Should I make changes on the c# side or b4j side??

C#:
private void Form1_Load(object sender, EventArgs e)
 {
     Console.WriteLine("این یک متن تستی میباشد"); //not ok
     Console.WriteLine("this is a test text."); //is ok
     Application.Exit();
 }

b4j code:
    Dim sh1 As Shell
    sh1.Initialize("sh1",File.Combine(File.DirApp,ExeFileName),Null)
    sh1.WorkingDirectory =  File.DirApp
    sh1.Run(-1)
    Wait For (sh1) sh1_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    If Success And ExitCode = 0 Then
        Log("Success")
        Log(StdOut)  'print ????????
    End If
 

Daestrum

Expert
Licensed User
Longtime User
You could try adding
B4X:
Console.OutputEncoding = Encoding.UTF8;
to the c# program.
 
Upvote 1
Solution

behnam_tr

Active Member
Licensed User
Longtime User
You could try adding
B4X:
Console.OutputEncoding = Encoding.UTF8;
to the c# program.
Thanks, I have already tested this
It works in the console application
But it does not work in the Windows Form application and gives an error

B4X:
 private void Form1_Load(object sender, EventArgs e)
 {
     Console.OutputEncoding = Encoding.UTF8; //error
      Console.WriteLine("test text....");
 }
vs2022:
Exception thrown: 'System.IO.IOException' in mscorlib.dll
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll
The handle is invalid.


At the moment, I have to convert it to a console application. Although there was no need for Windows App in this case
Thankful
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…