GithubHelp home page GithubHelp logo

jkachmar / utf8-conversions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shin-sakata/utf8-conversions

0.0 1.0 0.0 32 KB

A conversion library that assumes utf8.

License: BSD 3-Clause "New" or "Revised" License

Haskell 100.00%

utf8-conversions's Introduction

utf8-conversions A string conversion library that assumes utf8

Build Status License

This package provides a Data.Convertible.Utf8 library for easy conversion of many string types in Haskell

usage

import Data.Convertible.Utf8 (convert)

string :: String
string = "Hello world"

bytestring :: ByteString
bytestring = convert string

text :: Text
text = convert bytestring

A typeclass that represents something that can be converted. A Convertible a b instance represents an a that can be converted to a b.

class Convertible a b where
  convert :: a -> b

Support

  • String
  • ByteString
  • ByteStringBuilder
  • LazyByteString
  • ByteStringShort
  • Text
  • LazyText
  • TextBuilder
  • TextShort

Supports type conversion between the above types. Byte string is assumed to be in utf-8 encoding.

Why?

String conversion in haskell is more difficult than in other languages and needs to be easier.

In particular, the OverloadedStrings pragma does not work properly when creating a ByteString.

So why not other conversion libraries? There are many other conversion libraries that use the Maybe type for safety or are not explicitly stated as utf8.

Libraries that use maybe types are very labor intensive. Libraries that do not explicitly state UTF8 are insecure

Therefore, this library clearly states that it assumes UTF8 and performs the conversion without using the MAYBE type, which is both safe and easy.

Get involved!

If there's a bug or a better way to convert, please report it!

utf8-conversions's People

Contributors

shin-sakata avatar

Watchers

 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.