Problem:
How can I calculate the length of a UNICODE string?
Resolution:
The following code fragment illustrates one method of calculating the length of a UNICODE string:
working-storage section.
01 account-name-text pic n(20).
01 account-name-len pic 9(3).
01 w01-s1 pic 9(3).
procedure division.
initialize account-name-text.
move n"Paddy" to account-name-text.
move function length (account-name-text) to w01-s1.
perform varying w01-s1 from w01-s1 by -1
until account-name-text(w01-s1:1) not = n" "
or w01-s1 = 0
move w01-s1 to account-name-len
end-perform.
stop run.