How can I get special characters using elm-html module?

后端 未结 5 1241
伪装坚强ぢ
伪装坚强ぢ 2021-02-02 12:58

Disclaimer: I\'m brand new to Elm

I\'m fiddling around with the online Elm editor and I\'ve run into an issue. I can\'t find a way to get certain special charac

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 13:54

    You don't need to hunt the symbols, you can get them from a list like this one.

    If it's too bothersome to copy & paste, you can also create a helper function that you can use with your escaped characters like this:

    import Html exposing (..) 
    import String
    
    htmlDecode str = 
      let 
        replace (s1, s2) src= String.join s2 <| String.split s1 src    
        chrmap = 
          [ ("®", "®")
          , ("©", "©" )
          ] 
      in  
        List.foldl replace str chrmap
    
    main = text <| htmlDecode "hello ©" 
    

提交回复
热议问题