The bug program cannot read and recognize some normal Chinese characters

Post comments and suggestions for RoboTask here
Post Reply
a2511050547
Posts: 2
Joined: Sat Aug 10, 2024 1:04 pm

The bug program cannot read and recognize some normal Chinese characters

Post by a2511050547 »

The program bug causes it to fail to read and recognize some normal Chinese characters.

First, manually input some Chinese characters into the script, and monitor the window. These characters will not match the window, but you can select them from the window list in the program, and it will execute normally.

The program appears to treat the text as a string, but it fails to recognize a small portion of the manually entered (or copied) Chinese characters. For example, the "Start Task" program misinterprets the input as "Start any?", resulting in an error.

The same issue occurs with file reading. The following test text file opens normally in VSCode and Notepad.exe, but when Robotask tries to read it, some characters are replaced with ? instead of the expected Chinese characters.

Test file: test.txthttps://drive.google.com/file/d/1EDUC0u ... sp=sharing

Text encoded in UTF-8 can be read normally, but some Chinese characters are not recognized and are displayed as ?.

Image
Image
Image
Image
Oleg
Site Admin
Posts: 3136
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: The bug program cannot read and recognize some normal Chinese characters

Post by Oleg »

If your text (HTML text) has UTF8 coding you need read it as UTF8 text. Look at my examples below
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.

1-st example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1464"
Hide=INTEGER|0
ID=INTEGER|-439059366
LogOnAsUser=INTEGER|1
Name=STRING|"chinese text (1)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""fileName"" with value ""C:\temp\Test.txt"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"fileName"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"fileName"
varvalue=STRING|"C:\temp\Test.txt"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_SHOWTEXT"
Enabled=INTEGER|-1
Name=STRING|"Show Text"
Params=FOLDER

[Actions\Action2\Params]
autoclose=STRING|"0"
fromfile=STRING|"1"
line00000000=STRING|"{TextFileUTF8({fileName})}"
linecount=STRING|"1"
timeout=STRING|"10"
2-nd example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1465"
Hide=INTEGER|0
ID=INTEGER|1907355058
LogOnAsUser=INTEGER|1
Name=STRING|"chinese text (2)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""fileName"" with value ""C:\temp\Test.txt"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"fileName"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"fileName"
varvalue=STRING|"C:\temp\Test.txt"

[Actions\Action2]
ActionID=STRING|"A_READ_TXTFILE"
Enabled=INTEGER|-1
Name=STRING|"Read Text File ""{fileName}"" (65001)"
Params=FOLDER

[Actions\Action2\Params]
_rt_variables_produced=STRING|"Text"
codepage=STRING|"65001"
filename=STRING|"{fileName}"
replacenull=STRING|"1"
varname=STRING|"Text"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_SHOWTEXT"
Enabled=INTEGER|-1
Name=STRING|"Show Text"
Params=FOLDER

[Actions\Action3\Params]
autoclose=STRING|"0"
fromfile=STRING|"1"
line00000000=STRING|"{Text}"
linecount=STRING|"1"
timeout=STRING|"10"
The following test text file opens normally in VSCode and Notepad.exe...
Notepad and VSCode detects coding automatically. RoboTask reads file as it is.
Generally UTF8 text should have a UTF8 signature - byte order mask (BOM), but your HTML text does not. Therefore, RoboTask assumes that it is plain text.

The problem is related to BOM existence. You can test is in attached example.
In the ZIP simple task file and two text files with BOM and without BOM
ChineseTest.zip
(26.61 KiB) Downloaded 83 times
Oleg Yershov
Oleg
Site Admin
Posts: 3136
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: The bug program cannot read and recognize some normal Chinese characters

Post by Oleg »

We will try to do automatic encoding detection if the text does not contain BOM. I put this in our ToDo
Oleg Yershov
Post Reply