package shop.alien.util.common;

import java.nio.charset.StandardCharsets;

public class UrlEncode {
    public static String getUrlEncode(String str) {
        StringBuilder encodedStr = new StringBuilder();
        byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
        for (byte b : bytes) {
            String hex = Integer.toHexString(b & 0xFF);
            if (hex.length() == 1) {
                hex = "0" + hex;
            }
            encodedStr.append("%").append(hex.toUpperCase());
        }
        return encodedStr.toString();
    }
}