LoginSignup
0
0

More than 5 years have passed since last update.

ScalaでHTMLエンコードされた文字列をデコードする

Last updated at Posted at 2016-05-18

Javaで利用可能なHTMLエスケープライブラリunbescapeを利用します。

ライブラリの取得

build.sbtに以下の記述を追加します。

libraryDependencies += "org.unbescape" % "unbescape" % "1.1.3.RELEASE" 

文字列をデコード

デコード処理のサンプルコードです。

import org.unbescape.html.HtmlEscape

val encodedText = "<script>alert("foo")</script>"
val decodedText = HtmlEscape.unescapeHtml(encodedText)

println(decodedText) // <script>alert("foo")</script>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0