BookmarkSubscribeRSS Feed
Kodit
Fluorite | Level 6

Hi,

I'm running a Stored Process that sometimes will take Swedish letters as an input and I'm having trouble getting sas to Decode them properly.
so I have a request that looks like this, and the idea is that ref should resolve to ÖstersundHuvudlager.

http://myserver/SASStoredProcess/do?_PROGRAM=/DPPL/StoredProcesses/radbortagning&ref=%D6stersundHuvu...

However what I get is ;

REF=>stersundHuvudlager 

_ENCODING=UTF-8

_REQENCODING=UTF-8

 

I assume this has to do with that the sas encoding is utf-8 and the request isnt. But I'm unsure how to solve it.

 

 

2 REPLIES 2
jklaverstijn
Rhodochrosite | Level 12

When I look at your encoding using %D6 than I find that it encodes for Ö but not in UTF-8. This looks like a Latin encoding. The same character encoded using UTF-8 is %C3%96.

 

I found this doing this in a UTF-8 SAS session:

 

24         data _null_;
25         	sw='Östersund';
26         	swe=urlencode(sw);
27         	put _all_;
28         run;

sw=Östersund swe=%C3%96stersund _ERROR_=0 _N_=1

So I would have a look at the URL.

 

Hope this helps,

-- Jan

 

Vince_SAS
Rhodochrosite | Level 12

Here are some suggestions:

 

1. Always use UTF-8 based encoding. That means that Ö is encoded as %C3%96, and not %D6.

 

2. Specify this option in your SAS Stored Process code to ensure that the URLENCODE/URLDECODE functions use the UTF-8 encoding/decoding method:

 

options urlencoding=utf8;

This sample code simulates a stored process that gives the desired result:

 

options urlencoding=utf8;

*  Your input parameter;

%let REF=%nrstr(%%C3%%96stersundHuvudlager);

*  Your decoded input parameter;

%let REF_DECODED=%sysfunc(urldecode(&REF));

%put &=REF  &=REF_DECODED;

 

This technique should work with Unicode and non-Unicode SAS Stored Process Servers.

 

Vince DelGobbo
SAS R&D

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1803 views
  • 2 likes
  • 3 in conversation