cancel
Showing results for 
Search instead for 
Did you mean: 

Problem reading german text from txt file

mmostaquim
Level 4

Hi,

I have a txt file which contains German texts. When I try to read all texts with Read all lines from text file from Utility-File Management VBO, there is a problem extracting some German letters like ä,ü,ö,ß etc. In the file management VBO, I duplicated the “Read all lines from text file” page and changed the code. But still it can't extract the mentioned German letters. Below code I have written. It would be great if anyone can help me regarding this.

Text = ""

Try
' Read the file using UTF-8 encoding
Text = System.IO.File.ReadAllText(File_Name, System.Text.Encoding.UTF8)
Catch ex As Exception
' Handle exceptions by setting the output to an error message
Text = "Error: " & ex.Message
End Try

 

Regards,

Ekram

2 BEST ANSWERS

Helpful Answers

EricNewton
Level 4

Are you sure the encoding of the text file you are reading is UTF8? If it is ANSI for example I think that might be the issue.

If you have notepad++ you can open in there and check the lower right hand corner.

EricNewton_0-1733234625663.png

vs 

EricNewton_1-1733234638977.png

Or if you don't have notepad++ you can open in notepad and Save As and see what it defaults to, I don't think that is always a sure fire thing though.

View answer in original post

Hi @mmostaquim ,

Change the encoding to UTF-8 like below in Notepad (Save AS):

Chakkravarthi_PR_0-1733235495160.png

If it still doesnot work, change the code with :

Text = System.IO.File.ReadAllText(File_Name, System.Text.Encoding.GetEncoding("ISO-8859-1"))

and save the file encoding to UTF-8. Seems to be working from my end. 

you can find the code Identifiers here. 

 

View answer in original post

6 REPLIES 6

Hi @mmostaquim ,

I am using the Read All Text From file Action in the File Management - VBO it works well. Attached is the sample text. 

Chakkravarthi_PR_0-1733227891736.png

Read Text Code:

Chakkravarthi_PR_1-1733227987831.png

 

 

Hi @Chakkravarthi_PR,

I have checked the code of Read All Text From file Action in the File Management - VBO. The code is same like yours. For me, text looks like this "Gesch�ftsbereich"

I cannot find out where is the issue. 

EricNewton
Level 4

Are you sure the encoding of the text file you are reading is UTF8? If it is ANSI for example I think that might be the issue.

If you have notepad++ you can open in there and check the lower right hand corner.

EricNewton_0-1733234625663.png

vs 

EricNewton_1-1733234638977.png

Or if you don't have notepad++ you can open in notepad and Save As and see what it defaults to, I don't think that is always a sure fire thing though.

Unfornately, i do not have notepad++. I have tried with notepad and save as. I think it is defined as ANSI.

mmostaquim_0-1733235313498.png

 

Hi @mmostaquim ,

Change the encoding to UTF-8 like below in Notepad (Save AS):

Chakkravarthi_PR_0-1733235495160.png

If it still doesnot work, change the code with :

Text = System.IO.File.ReadAllText(File_Name, System.Text.Encoding.GetEncoding("ISO-8859-1"))

and save the file encoding to UTF-8. Seems to be working from my end. 

you can find the code Identifiers here. 

 

hi @Chakkravarthi_PR, thanks for the solution. After saving the txt file with UTF format, Read All Text From file Action in the File Management - VBO can read german letters.