Share via

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

Developer technologies | VB
Developer technologies | C#
Developer technologies | 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.

0 comments No comments

Answer accepted by question author
  1. Viorel 126.9K 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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.