Как через "Выполнить код" преобразовать определённый текст в процентный HEX?



  • Как через "Выполнить код" преобразовать всегда разные ссылки в процентный HEX?

    Задача из:

    http://community.bablosoft.com/topic/9335/%D0%BA%D0%B0%D0%BA-%D1%87%D0%B5%D1%80%D0%B5%D0%B7-%D0%B2%D1%8B%D0%BF%D0%BE%D0%BB%D0%BD%D0%B8%D1%82%D1%8C-%D0%BA%D0%BE%D0%B4-%D0%BF%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D1%8C-%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D1%91%D0%BD%D0%BD%D1%8B%D0%B9-%D1%82%D0%B5%D0%BA%D1%81%D1%82-%D0%B2-%D0%BF%D1%80%D0%BE%D1%86%D0%B5%D0%BD%D1%82%D0%BD%D1%8B%D0%B9-hex
    

    Получить:

    %68%74%74%70%3a%2f%2f%63%6f%6d%6d%75%6e%69%74%79%2e%62%61%62%6c%6f%73%6f%66%74%2e%63%6f%6d%2f%74%6f%70%69%63%2f%39%33%33%35%2f%25%44%30%25%42%41%25%44%30%25%42%30%25%44%30%25%42%41%2d%25%44%31%25%38%37%25%44%30%25%42%35%25%44%31%25%38%30%25%44%30%25%42%35%25%44%30%25%42%37%2d%25%44%30%25%42%32%25%44%31%25%38%42%25%44%30%25%42%46%25%44%30%25%42%45%25%44%30%25%42%42%25%44%30%25%42%44%25%44%30%25%42%38%25%44%31%25%38%32%25%44%31%25%38%43%2d%25%44%30%25%42%41%25%44%30%25%42%45%25%44%30%25%42%34%2d%25%44%30%25%42%46%25%44%31%25%38%30%25%44%30%25%42%35%25%44%30%25%42%45%25%44%30%25%42%31%25%44%31%25%38%30%25%44%30%25%42%30%25%44%30%25%42%37%25%44%30%25%42%45%25%44%30%25%42%32%25%44%30%25%42%30%25%44%31%25%38%32%25%44%31%25%38%43%2d%25%44%30%25%42%45%25%44%30%25%42%46%25%44%31%25%38%30%25%44%30%25%42%35%25%44%30%25%42%34%25%44%30%25%42%35%25%44%30%25%42%42%25%44%31%25%39%31%25%44%30%25%42%44%25%44%30%25%42%44%25%44%31%25%38%42%25%44%30%25%42%39%2d%25%44%31%25%38%32%25%44%30%25%42%35%25%44%30%25%42%41%25%44%31%25%38%31%25%44%31%25%38%32%2d%25%44%30%25%42%32%2d%25%44%30%25%42%46%25%44%31%25%38%30%25%44%30%25%42%45%25%44%31%25%38%36%25%44%30%25%42%35%25%44%30%25%42%44%25%44%31%25%38%32%25%44%30%25%42%44%25%44%31%25%38%42%25%44%30%25%42%39%2d%68%65%78
    

    ... без использования онлайн сервисов.



  • @Revers

    function hex(str){
     return str.replace(/\S/g, function(char){
       return '%' + char.charCodeAt(0).toString(16)
     })
    }
    
    [[HEX]] = hex([[TEXT]]);
    


  • @Revers

    [[HEX]] = encodeURI([[TEXT]])
    


  • @Fox Это не то(урленкод не кодидрует инглиш буквы). То что предложил UserTrue - отлично работает.


Log in to reply