Giter Club home page Giter Club logo

erlang-iconv's Introduction

About

Erlang-iconv is a fork of the iconv in Jungerl. I pulled it out of jungerl because I only wanted iconv, not all the other stuff in jungerl and because the jungerl build system wasn't very helpful on anything but linux.

erlang-iconv has been built and tested on the following platforms:

  • Linux
  • FreeBSD
  • OpenBSD
  • OSX

It should also build on NetBSD and most other UNIX-like systems. I haven't bothered to try on windows yet.

Usage

Here's some sample usage converting some shift-jis text to utf-8:

1> iconv:start().
{ok,<0.53.0>}
2> X = <<83,97,109,112,108,101,58,32,142,132,32,130,205,32,131,67,32,131,147,32,131,79,32,131,71,32,130,197,32,130,183,13,10>>.
<<83,97,109,112,108,101,58,32,142,132,32,130,205,32,131,
  67,32,131,147,32,131,79,32,131,71,32,130,197,32,...>>
3> io:format("~s~n", [X]).
Sample:
         Í C  O G Å ·

ok
4> io:format("~ts~n", [X]).
** exception exit: {badarg,[{io,format,
                                [<0.25.0>,"~ts~n",
                                 [<<83,97,109,112,108,101,58,32,142,132,32,130,205,32,
                                    131,67,32,131,147,...>>]]},
                            {erl_eval,do_apply,5},
                            {shell,exprs,6},
                            {shell,eval_exprs,6},
                            {shell,eval_loop,3}]}
     in function  io:o_request/3
5> {ok, CD} = iconv:open("utf-8", "shift-jis").
{ok,<<176,86,91,1,0,0,0,0>>}
6> {ok, Output} = iconv:conv(CD, X).
{ok,<<83,97,109,112,108,101,58,32,231,167,129,32,227,129,
      175,32,227,130,164,32,227,131,179,32,227,130,176,
      ...>>}
7> io:format("~ts~n", [Output]).
Sample: 私 は イ ン グ エ で す
8> iconv:close(CD).
ok

As you can see, before we passed it through iconv it was an unprintable mess.

Installation

To install, use rake:

rake
sudo rake install

If the compilation of the C part fails with errors about iconv, you have to specify the prefix where iconv is located, for example on FreeBSD:

rake iconv=/usr/local

And if you don't have iconv or it's development header installed (and iconv isn't part of your C libary) install it.

erlang-iconv's People

Contributors

vagabond avatar

Watchers

James Cloos 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.