/**
 * @Author: Kane Wang <wangkane@qq.com>
 * @Date: 2026-02-07 21:36:35
 * @LastEditors: Kane Wang
 * @LastModified: 2026-02-07 21:36:35
 * @FilePath: src/main/java/com/cpic/xim/utils/utils.java
 * @Description:
 *
 *               Copyright (c) 2025 by Kane All rights reserved
 */
package com.cpic.xim.utils;

public class utils
{
    public static String encodeURL( String urlString )
    {
        StringBuilder encodedURLString = new StringBuilder( urlString.length() * 3 );
        char[]        charArray       = urlString.toCharArray();
        
        for ( char c : charArray )
        {
            switch ( c )
            {
                case '%':
                    encodedURLString.append( PERCENT );
                    break;
                case ' ':
                    encodedURLString.append( SPACING );
                    break;
                case '+':
                    encodedURLString.append( PLUS );
                    break;
                case '/':
                    encodedURLString.append( FORWARD_SLASH );
                    break;
                case '?':
                    encodedURLString.append( QUESTION_MASK );
                    break;
                case '&':
                    encodedURLString.append( AMPERSAND );
                    break;
                case '#':
                    encodedURLString.append( SHARP );
                    break;
                case '=':
                    encodedURLString.append( PLUS );
                    break;
                default:
                    encodedURLString.append( c );
            }
        }
        
        return encodedURLString.toString();
    }
    
    static final String SHARP         = "%23";
    static final String PLUS          = "%2B";
    static final String FORWARD_SLASH = "%2F";
    static final String QUESTION_MASK = "%3F";
    static final String SPACING       = "%20";
    static final String EQUAL         = "%3D";
    static final String PERCENT       = "%25";
    static final String AMPERSAND     = "%26";
    
}
