ReadLine not see Cyrillic

Blitz3D Forums/Blitz3D Beginners Area/ReadLine not see Cyrillic

Xaker1493(Posted 2016) [#1]
Hello.
Sorry for the awful English.
At me such problem:
The program when reading a file * .ini does not see Russian text.
Help please solve my problem.

Function GetINISectionLocation%(file$, section$)
Local Temp%
Local f% = ReadFile(file)

section = Lower(section) 

Local n%=0 
While Not Eof(f) 
Local strtemp$ = ReadLine(f)
n=n+1
If Left(strtemp,1) = "[" Then
strtemp$ = Lower(strtemp)

Temp = Instr(strtemp, section)
If Temp>0 Then
If Mid(strtemp, Temp-1, 1)="[" Or Mid(strtemp, Temp-1, 1)="|"Then
CloseFile f
Return n
EndIf
EndIf
EndIf
Wend
	
CloseFile f
End Function 



Dan(Posted 2016) [#2]
as i dont have any cyrilic text here to play with, i would suggest you,
to first make a test.

Write a new program, where you will first, print the text, in the cyrylic, on the screen,
then write the same text, with writeline to a file.
close file, open it for read, and then read that same text, and print it again to the screen.

if this doesnt work then try loading a font, which can display the cyrilic chars, and see if the test from above does work.

This simple test may take a bit to write, but you will know if the readline can read it or not.

Maybe you could upload a sample, with the cyrilic text ?


edit:
or try debugging the function above with

with debugger: 

Local strtemp$ = ReadLine(f)
debuglog strtemp$
stop

or 

without debugger:

Local strtemp$ = ReadLine(f)
Print  strtemp$
print "press key"
waitKey()



Xaker1493(Posted 2016) [#3]
Thank you for your response.
But the code is not mine - http://www.scpcbgame.com/.
I decided to Russify game.
All has translated, but the text is displayed in * .ini cut or nehvataet letters is dependent on the encoding:
achievementstrings.ini
[s0]
string1=Биологическая опасность
image=Achv008
AchvDesc=Дoстичь камеры содержания SCP-008

1) UNICODE (UTF-8)


2) ANSI (windows-1251)


But if you add text to the beginning of any character (example: `) I use
Replace $ (string1," `", "")


achievementstrings.ini
[s0]
string1=`Биологическая опасность`
image=Achv008
AchvDesc=`Дoстичь камеры содержания SCP-008`



That problem is solved, but if you want to find a text in [Text|Text], the command useless.

SCP-294.ini
[Арбуз|Кефир]
color=255,255,255
alpha=0.5
blur=5
dispensesound=SFX\294\dispense1.ogg
sound=SFX\294\cough.ogg
message=Тут пусто


Runtime Error
Parameter must be greater than 0
If Mid(strtemp, Temp-1, 1)="[" Or Mid(strtemp, Temp-1, 1)="|"Then



Dan(Posted 2016) [#4]
runtime error should not happen,because of the previous line:

If Temp>0 Then


with low information, i can only guess what is happening.

im using crimson editor, and copy and pasted following lines into it:

[s0]
string1=`Биологическая опасность`
image=Achv008
AchvDesc=`Дoстичь камеры содержания SCP-008`

[Арбуз|Кефир]
color=255,255,255
alpha=0.5
blur=5
dispensesound=SFX\294\dispense1.ogg
sound=SFX\294\cough.ogg
message=Тут пусто

and saved it.

The text appears with non cyrilic chars, to make them appear i have set the font as follow:

arial, regular, 12 and changed the script to cyrilic.

that made the cyrilic chars visibile.

next, in CE, under Document\Encoding type i have set it to Ascii. - the cyrilic chars were still visibile.
And again saved it.

now, to test the function i have used following code:

Print GetINISectionLocation("r:\test.txt","Арбуз|Кефир")

WaitKey()

Function GetINISectionLocation%(file$, section$)
	Local Temp%
	Local f% = ReadFile(file)
	
	section = Lower(section) 
	
	Local n%=0 
	While Not Eof(f) 
		Local strtemp$ = ReadLine(f)
		n=n+1
		If Left(strtemp,1) = "[" Then
			strtemp$ = Lower(strtemp)
			
			Temp = Instr(strtemp, section)
			If Temp>0 Then
				If Mid(strtemp, Temp-1, 1)="[" Or Mid(strtemp, Temp-1, 1)="|"Then
					CloseFile f
					Return n
				EndIf
			EndIf
		EndIf
	Wend
	
	CloseFile f
End Function 


and the result printed was 6, which is the line number,in which the searched text appears.

i guess, that file needs to be in the ascii format, so that the readline command returns the exact string.

I suggest to use an hex editor, to check the format in which the data is saved.
Like this Freeware editor,HxD


Xaker1493(Posted 2016) [#5]
Did how do you wrote
Print GetINISectionLocation("r:\test.txt","Арбуз|Кефир")

WaitKey()

Function GetINISectionLocation%(file$, section$)
	Local Temp%
	Local f% = ReadFile(file)
	
	section = Lower(section) 
	
	Local n%=0 
	While Not Eof(f) 
		Local strtemp$ = ReadLine(f)
		n=n+1
		If Left(strtemp,1) = "[" Then
			strtemp$ = Lower(strtemp)
			
			Temp = Instr(strtemp, section)
			If Temp>0 Then
				If Mid(strtemp, Temp-1, 1)="[" Or Mid(strtemp, Temp-1, 1)="|"Then
					CloseFile f
					Return n
				EndIf
			EndIf
		EndIf
	Wend
	
	CloseFile f
End Function 


Everything works fine.

But in a game nothing has changed.
All the same.

I here have laid out a file
Download


Dan(Posted 2016) [#6]
Your download link is giving following error:

Error
This document is available only to its owner.



if you can, use the www.tinyupload.com.

Can you describe what you are trying to do with blitzbasic and this game ?

i mean, the game has this ini files, which are translated to Russian.
But the game is not displaying the text completely, or ?
or not correctly ?
so what does blitzbasic and the functions have to do with it ?
more information from your side would be helpfull.

im downloading the game atm and ill try to look further in it.


Xaker1493(Posted 2016) [#7]
Translated all.

But the lines in the file
Data\SCP-294.ini
and
Data\achievementstrings.ini
display without the initial letters or incompletely

Source code:
https://mega.nz/#!7Ug3XAyC!zvmbnPnpkSdJi45yzY-czYoroNvtk-exHqdKkTzudXI


Xaker1493(Posted 2016) [#8]
achievementstrings.ini
[s0]
string1=Биологическая опасность
image=Achv008
AchvDesc=Дoстичь камеры содержания SCP-008



SCP-294.ini
[Арбуз|Кефир]
color=0,0,0
alpha=0.0
refusemessage=There is nothing to drink in the cup.
dispensesound=SFX\294\dispense0.ogg






Bobysait(Posted 2016) [#9]
The file (on your mega link) is unavailable.


Xaker1493(Posted 2016) [#10]
Fixed
Source code:
https://mega.nz/#!7Ug3XAyC!zvmbnPnpkSdJi45yzY-czYoroNvtk-exHqdKkTzudXI


Dan(Posted 2016) [#11]
The sourcecode is not running here, the game gives me Runtime error, Mav, because of some setbuffer_ troubles ...


Xaker1493(Posted 2016) [#12]
Сopy the in a directory Blitz3D
userlibs -> C:\Program Files (x86)\Blitz3D

SCP - Containment Breach Run Main.bb through Blitz3D


Xaker1493(Posted 2016) [#13]
In Game using F3 open the console commands.
In the console input room2cafeteria
to teleport to a SCP-294.


Dan(Posted 2016) [#14]
The userlibs are copied allready.
The Error comes from something else.
Both source code, from your url, and the Game source from the http://www.scpcbgame.com/ do not work.
They give all the same error.

I can compile it, the error comes after the compiled game is started.


Xaker1493(Posted 2016) [#15]
Strangely?
My normally run




Rick Nasher(Posted 2016) [#16]
This is pretty awesome.


Xaker1493(Posted 2016) [#17]
I checked.
With the new version does not work Blits3D.
Only version 1.99


Rick Nasher(Posted 2016) [#18]
Not so. I'm using V1.106 and all good on Win 10 x64 BTW. But I do have FastExt Retail V1.17 installed, dunno if matters. Above Blitz3D V1.106 there are some issues with FastExtension I believe.. So there's probably where the problem is.


Dan(Posted 2016) [#19]
iv downloaded the 1.106 and installed. Now the game works.
It must be some incompatibility between the fast extensions, and the later versions of blitz.

Anyway, how much of the Game have you translated yet ?
And have you found the sollution to that error, yet ?

Great game,btw.


Xaker1493(Posted 2016) [#20]
I found a problem.
Trim$() and Lower$() does not work with Russian text.


Dan(Posted 2016) [#21]
ok, well, both function can be rewritten to act like they work with them.
or, using fonts which have cyrilic chars instead of normal chars.


Dan(Posted 2016) [#22]
i was just browsing the Code arcive, and found this