Read Text File: UTF-7 is disabled

Hi community,

Can you help me with:
Read Text File: One or more errors occurred. (Support for UTF-7 is disabled. See SYSLIB0001 warning - .NET | Microsoft Learn for more information.)

image

After the update to 22.10 version this activity does not working properly. If i use “utf-8” it’s working but it cannot read some symbols like © or ®.

Any thought ?

Thanks,
Nikos

@nrok

Try using invoke code and read the file as below …

#Disable Warning SYSLIB0001
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance)
Data = System.IO.File.ReadAllText(filePath, System.Text.Encoding.GetEncoding("utf-7"))

Hope this helps

cheers

1 Like

Thanks for you reply.

I tried with Invoke code, needs “System.Text.CodePagesEncodingProvider.Instance” as input

but the results was the same:

RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.NotSupportedException: Support for UTF-7 is disabled. See SYSLIB0001 warning - .NET | Microsoft Learn for more information.

Hi @nrok

UTF-7 is no longer supported in programming, you should migrate to UTF-8 instead

it will read the symbols you need as expected
image

Regards

1 Like

@nrok

Please try this code…

I tested from my end it did read…Can you check

Dim utf7Encoding As New System.Text.UTF7Encoding()
Dim fallback As New System.Text.DecoderReplacementFallback("?")
utf7Encoding = CType(utf7Encoding.Clone(), System.Text.UTF7Encoding)
utf7Encoding.DecoderFallback = fallback
Using streamReader As New StreamReader(filePath, utf7Encoding)
       Data = streamReader.ReadToEnd()
End Using

cheers

1 Like

HI,

Can you try the following sample? This sample converts from UTF7 based text to string type.

Sample20230324-7v2.zip (3.4 KB)

Regards,

1 Like

Hi all,

I tried with each comment’s way but i didn’t manage solve the issue.

Finally, i changed the encoding of the txt file (utf8) and add the two symbol again after the changed.
Now it working!

Thanks all !!!
Nikos

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.