How can I encode a URL String?

Question ID : 211
Created on 2013-10-25 at 11:33 AM
Author : Veryant Support []

Online URL :

You can work with the OOP statements using the Java class named "", available with the Java Runtime, useful to encode a URL string:

The following is an example of a COBOL program that encodes a string using UTF-8 as the encoding scheme:

program-id. pencode.
configuration section.
 class jencoder as ""
 class jstring as "java.lang.String"
 class jencodeEx as ""
working-storage section.
77 w-jencoder object reference jencoder.
77 w-string object reference jstring.
77 var pic x any length.
procedure division.
    set w-string to jstring:>new(""The string ΓΌ@foo-bar")
    set var to jencoder:>encode(w-string, "UTF-8")      
    display var
 catch jencodeEx
    display exception-object
 stop run.

Back to Original Question