yesterday
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
Answered! Go to Answer.
yesterday
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.
vs
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.
yesterday
Hi @mmostaquim ,
Change the encoding to UTF-8 like below in Notepad (Save AS):
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.
yesterday
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.
Read Text Code:
yesterday
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.
yesterday
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.
vs
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.
yesterday
Unfornately, i do not have notepad++. I have tried with notepad and save as. I think it is defined as ANSI.
yesterday
Hi @mmostaquim ,
Change the encoding to UTF-8 like below in Notepad (Save AS):
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.
2 hours ago
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.