java - How to decode to UTF-8 String from Hex encoded string -
html javascript string such as:
htmlString = "https \ x3a \" X2f \ x2ftest.com " < / Pre>
But I want to explain it as below:
str = "https://test.com" This means, I would like a Util API:
public static string decodehex (string html string) {// decode and converter here} public static zero main (string ... args) {String html string C = "https \ x3a \ x2f \ x2ftest.com"; string should be str = decodeHex (html string); // str should be "https://test.com"} Does anybody know how to implement this API - decodeHex?
Must be enough I'm implementing hexadecode and sorting input incorrectly as an exercise for you. public string decode (string encoded) { StringBinder SB = New stringbilder (); For (int i = 0; i & lt; encoded; langhe (); i ++) {if (encoded.chart at (i) == '\' and & amp; amp; (i + 3) & lt ; Encoded.Length () & amp; Amp; encoded.chart (I + 1) == 'x') {sb.append (hexadecod (encoded. Substring (i + 2, i + 4)); I + = 3; } Other {sb.append (encoded.chart (i)); }} Return sb.toString; }
Comments
Post a Comment