Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:18
eiconv
0001-Add-some-documentation.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Add-some-documentation.patch of Package eiconv
From 993ef6031a46d213a42ea9301c77414d8957ddf4 Mon Sep 17 00:00:00 2001 From: Yoan Tournade <yoan@ytotech.com> Date: Wed, 23 Aug 2017 23:16:39 +0200 Subject: [PATCH] Add some documentation --- README.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4b73c6e..31750d4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,77 @@ -eiconv [![Build Status](https://secure.travis-ci.org/mmzeeman/eiconv.png?branch=master)](http://travis-ci.org/mmzeeman/eiconv) -====== +# Erlang NIF wrapper for iconv -Erlang NIF wrapper for iconv +[![Build Status](https://secure.travis-ci.org/zotonic/eiconv.png?branch=master)](http://travis-ci.org/zotonic/eiconv) + +An Erlang wrapper for the character set conversion utility [iconv](https://en.wikipedia.org/wiki/Iconv). + +## Getting started + +### Include as a dependency + +Using [rebar3](http://www.rebar3.org/), add the dependency to your `rebar.config` file: + +```erlang +{deps, [ + {eiconv, ".*", {git, "git://github.com/zotonic/eiconv.git", {branch, "master"}}} +]}. +``` + +You must also enable the compilation of `eiconv_nif.so` through [port_compiler](https://github.com/blt/port_compiler). Again, add in your `rebar.config` file: + +```erlang +{overrides, + [{override, eiconv, + [ + {plugins, [pc]}, + {port_env, [{"darwin|freebsd|openbsd", "LDFLAGS", "$LDFLAGS -liconv"}, + {"freebsd|openbsd", "CFLAGS", "$CFLAGS -I/usr/local/include"}, + {"freebsd|openbsd", "LDFLAGS", "$LDFLAGS -L/usr/local/lib"}]}, + + {port_specs, [{"priv/eiconv_nif.so", ["c_src/*.c"]}]}, + {artifacts, ["priv/eiconv_nif.so"]}, + + {provider_hooks, [ + {post, + [ + {compile, {pc, compile}}, + {clean, {pc, clean}} + ] + }] + } + ]} +]}. +``` + +### Use `eiconv` module + +To convert from `utf-8` to `ascii`: + +```erlang +ToConvert = "123", +{ok, Converted} = eiconv:convert("utf-8", "ascii", ToConvert)), +io:format("Converted '~s' to '~s'~n", [ToConvert, Converted]) +``` + +## `eiconv` API + +### Using `convert/3` + +```erlang +{ok, Converted} = eiconv:convert("utf-8", "ascii", "123")) +``` + +### Using CD (Conversion Descriptor) + +```erlang +{ok, CD} = eiconv:open("utf8", "ascii"), +{ok, Converted} = eiconv:conv(CD, "123")), +ok = eiconvclose(CD) +``` + +## Authors + +Wrapper provided by Maas-Maarten Zeeman and the [Zotonic](https://github.com/zotonic) team. + +* [Maas-Maarten Zeeman](https://github.com/mmzeeman) +* [Arjan Scherpenisse](https://github.com/arjan) +* [Marc Worrell](https://github.com/mworrell) -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor