Git Product home page Git Product logo

networkparser's Introduction

NetworkParser

C# Classes to handle text-based parsing for protocols like Gopher and Telnet

NetworkParsers.ParseCRLF.SplitCRLF (byte[] data, SplitState state)

Splits the given data into lines seperated by CRLF. Because many actual servers incorrectly use LF or CR, will also split on those characters by themselves.

NetworkParsers.UTf8.IsUtf8 (byte[] data, int length-1)

Returns True if the input is valid UTF8. Has the same function signature as a popular C# class so that it can be a drop-in replacement. The original utf8checker.IsUtf8 has a couple of problems -- it's Gnu GPL, which I don't want to use for my own code, and it's got a bug where utf8 sections at the end of a byte array will be flagged as incorrect. It also hardly has any tests, and it doesn't compare its output against the Window UWP UTF8 conversion routines.

Features of my IsUtf8 method

My IsUtf8 method has a couple of goals that some other checkers don't share.

  1. My version is "robust" when given sub-optimal UTF8. For example, a NUl char should be present as just a plain NUL char in UTF8 since that's the shortest possible version. But some people prefer to encode it using Modified UTF8 as C0 80, a two-byte overlong sequence that when converted into unicode chars will be a NUL.

  2. My version includes tests to compare its results against the Microsoft decoders. The next step afer determining that a byte array is UTF8 is presumably to convert it to a string using one of the three main converters used in UWP C# programs. I never want to have my IsUtf8 say that a byte array is UTF8 only to have the conversion throw an exception.

  3. My version includes unit tests include testing randomly generated UTF8 and invalid UTF8 sequences. This give more assurances that the code is correct.

networkparser's People

Contributors

pedasmith avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.