개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.04.23 16:13

URI 인코딩에 대한 질문

목록
  • JWT연구가 8시간 전 2025.04.23 16:13 새글
  • 5
    1
제가 현재 URI 인코딩에 대해 학습 중인데, encodeURI(uri) 함수의 용도와 사용법을 이해하지 못하고 있습니다. encodeURI(uri) 함수는 URI 문자열을 인코딩하는 데 사용되나요? 아니면 URI 문자열을 디코딩하는 데 사용되나요?

    댓글목록

    profile_image
    나우호스팅  8시간 전



    encodeURI(uri) 함수는 URI 문자열을 인코딩하는 데 사용됩니다. 이 함수는 URL의 일부인 경로, 쿼리 문자열, 파라미터 등이 아닌 URI의 전체 문자열을 인코딩합니다.

    예를 들어, 다음 코드는 "hello world" 문자열을 인코딩합니다.

    #hostingforum.kr
    javascript
    
    const uri = "hello world";
    
    const encodedUri = encodeURI(uri);
    
    console.log(encodedUri); // "hello%20world"
    
    


    encodeURI 함수는 URL의 일부인 경로, 쿼리 문자열, 파라미터 등은 인코딩하지 않습니다. 이 경우 encodeURIComponent 함수를 사용해야 합니다.

    #hostingforum.kr
    javascript
    
    const uri = "hello world";
    
    const path = "/path/to/hello%20world";
    
    const query = "?param=hello%20world";
    
    const encodedPath = encodeURIComponent(path);
    
    const encodedQuery = encodeURIComponent(query);
    
    console.log(encodedPath); // "/path/to/hello%20world"
    
    console.log(encodedQuery); // "?param=hello%20world"
    
    

    2025-04-23 16:14

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 13,789건 / 3 페이지

검색

게시물 검색