# How to decode HTML code while encode in SHIFT\_JIS

**URL:** <https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634>\
**Category:** Learning\
**Tags:** opam\
**Created:** [April 9, 2021, 9:50am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634 "2021-04-09T09:50:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohit](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Rohit](https://discuss.ocaml.org/u/Rohit)\
**Post date:** [April 9, 2021, 9:50am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634/1 "2021-04-09T09:50:25Z")

</div>

Hello,  
I have code to convert HTML to text.  
but if HTML code is encoded with **SHIFT\_JIS** it is a fail.  
can you help me to decode SHIFT\_JIS?  
and how to do that in OCAML.

Thanks and Regards,  
Rohit

---

<div class="post-metadata">

**Author:** ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)\
**Post date:** [April 9, 2021, 11:07am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634/2 "2021-04-09T11:07:41Z")

</div>

Which library are you using for the conversion? According to wikipedia the SHIFT\_JIS encoding of the html special character is compatible with ascii.

How does it fail on SHIFT\_JIS encoded page (with which kind of errors)?

Can you link an example that fails?

---

<div class="post-metadata">

**Author:** ![Rohit](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Rohit](https://discuss.ocaml.org/u/Rohit)\
**Post date:** [April 9, 2021, 11:25am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634/3 "2021-04-09T11:25:54Z")

</div>

I can not share code because it is confidential.  
we use the UTF\_8 library

and can you have some sample code to decode Shift\_JIS to UTF-8

---

<div class="post-metadata">

**Author:** ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)\
**Post date:** [April 9, 2021, 11:30am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634/4 "2021-04-09T11:30:28Z")

</div>

If you just want to convert from Shift JIS to UTF\_8, using `iconv` might the easiest path? I am not sure if there is any Shift JIS decoder library in OCaml.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [April 9, 2021, 11:40am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634/5 "2021-04-09T11:40:40Z")

</div>

I may be wrong but I’m pretty sure [`Camomile`](https://github.com/yoriyuki/Camomile) supports Shift\_JIS.

---

<div class="post-metadata">

**Author:** ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)\
**Post date:** [April 9, 2021, 11:55am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634/6 "2021-04-09T11:55:46Z")

</div>

You are right, and decoding Shift\_JIS is even part of the camomille test suite.

---

<div class="post-metadata">

**Author:** ![Rohit](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Rohit](https://discuss.ocaml.org/u/Rohit)\
**Post date:** [April 12, 2021, 4:22am UTC](https://discuss.ocaml.org/t/how-to-decode-html-code-while-encode-in-shift-jis/7634/7 "2021-04-12T04:22:55Z")

</div>

Hello all,

Thanks for your replay☺.

I am beigginiear for OCaml langauge. If any knows how to do handle this situation please help me out.  
If you give me snip of code that better to know me.
