Advertisement
uniblab

CodePageHelper

Mar 9th, 2018
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using System.Linq;
  2.  
  3. namespace Icod.Wod {
  4.  
  5.     public static class CodePageHelper {
  6.  
  7.         public static System.Text.Encoding GetCodePage( System.String codePage ) {
  8.             System.Text.Encoding output = null;
  9.  
  10.             System.Int32 cpNumber;
  11.             if ( System.Int32.TryParse( codePage, out cpNumber ) ) {
  12.                 output = System.Text.Encoding.GetEncoding( cpNumber );
  13.             }
  14.             if ( null == output ) {
  15.                 output = System.Text.Encoding.GetEncoding( codePage );
  16.             }
  17.  
  18.             return output;
  19.         }
  20.  
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement