GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ReClass.NET/ReClass.NET/Extensions/EncodingExtensions.cs at master · ReClassNET/ReClass.NET

Expand file tree

/

EncodingExtensions.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
40 lines (37 loc) · 1.11 KB
/

EncodingExtensions.cs

Copy path

File metadata and controls

40 lines (37 loc) · 1.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Text;
namespace ReClassNET.Extensions
{
public static class EncodingExtension
{
/// <summary>Gets the (perhaps wrong) byte count per character. Special characters may need more bytes.</summary>
/// <param name="encoding">The encoding.</param>
/// <returns>The byte count per character.</returns>
public static int GuessByteCountPerChar(this Encoding encoding)
{
if (encoding.IsSameCodePage(Encoding.UTF8) || encoding.CodePage == 1252 /* Windows-1252 */ || encoding.IsSameCodePage(Encoding.ASCII))
{
return 1;
}
if (encoding.IsSameCodePage(Encoding.Unicode) || encoding.IsSameCodePage(Encoding.BigEndianUnicode))
{
return 2;
}
if (encoding.IsSameCodePage(Encoding.UTF32))
{
return 4;
}
throw new NotImplementedException();
}
/// <summary>
/// Checks if the code page of both encodings is equal.
/// </summary>
/// <param name="encoding"></param>
/// <param name="other"></param>
/// <returns></returns>
public static bool IsSameCodePage(this Encoding encoding, Encoding other)
{
return encoding.CodePage == other.CodePage;
}
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.