1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Swift】絵文字もエンコード / デコードできる👍

Last updated at Posted at 2018-12-30

空白や記号だけでなく、絵文字もエンコード・デコードできる👀🎉

エンコード

var text = "www.hogehoge.co.jp/空白 記号〜「】★♪ 絵文字😄⭐💖"
text = text.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)!
let url = URL(string: text)
print(url)


スクリーンショット 2018-12-31 1.39.44.png

デコード

let decodedString = text.removingPercentEncoding!
print(decodedString)


スクリーンショット 2018-12-31 0.53.40.png
🎉🎉🎉

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?