Get encoding from Encoding.EncodingName

Chery Lidan 20 Reputation points
2024-04-22T15:43:18.0133333+00:00

Hello

I need to get the Encoding from a string which is a valid string : Encoding.EncodingName

ie: Korean (EUC) or Central European (Windows)

Having this string, how to get the proper encoding?

Encoding.GetEncoding("Central European (Windows)") will not work.

Thanks

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,341 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,591 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.8K Reputation points
    2024-04-22T16:05:20.1633333+00:00

    Try this:

    Encoding encoding = Encoding.GetEncodings( ).First( e => e.DisplayName == "Korean (EUC)" ).GetEncoding( );
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful