Given the string is assigned to a variable, say /Str, then:
Str Str length 1 sub 1 getinterval (s) eq
{
/Str Str (') cat def
}
{
/Str Str ('s) cat def
} ifelse
The code above implies that a catenation operator i.e.
S1 S2 cat -> S1S2
is already defined.
Hope that this helps