我试图弄清楚这个网址中编码的字符是什么: http://whatyouth.com/9236/roadtripppp-%f0%9f%8c-%b4%f0%9f%9a-%8c%f0%9f%90-roadtrip-throwback-again-sorry-missingsummer-palmtrees-rememberwhatyouth/
当我使用javascript函数decodeURI
时,我收到此错误:
decodeURI("http://whatyouth.com/9236/roadtripppp-%f0%9f%8c-%b4%f0%9f%9a-%8c%f0%9f%90-roadtrip-throwback-again-sorry-missingsummer-palmtrees-rememberwhatyouth/")
> URIError: URI malformed
有人知道这些角色是什么吗?
%f0%9f%8c
%b4%f0%9f%9a
%8c%f0%9f%90
答案 0 :(得分:0)
我想这是一个Windows-1252编码:ASCII Encoding Reference (W3Schools)(对不起W3Schools链接...不是我最喜欢的网站)
我在我的网址中用'\ x'替换了每个'%',我在这个答案中使用了函数:https://stackoverflow.com/a/4129920/3484498
var url = 'http://whatyouth.com/9236/roadtripppp-\xf0\x9f\x8c-\xb4\xf0\x9f\x9a-\x8c\xf0\x9f\x90-roadtrip-throwback-again-sorry-missingsummer-palmtrees-rememberwhatyouth/';
decodeBytes(url,'cp1252');
> "http://whatyouth.com/9236/roadtripppp-ðŸŒ-´ðŸš-ŒðŸ�-roadtrip-throwback-again-sorry-missingsummer-palmtrees-rememberwhatyouth/"
decodeBytes(url,'cp1251');
> "http://whatyouth.com/9236/roadtripppp-рџЊ-ґрџљ-Њрџђ-roadtrip-throwback-again-sorry-missingsummer-palmtrees-rememberwhatyouth/"