substr vs char.substr

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

substr vs char.substr

<B.Y.>
Hello all,

What really is the difference between SUBSTR and CHAR.SUBSTR string
functions? I have used both in the past, but does anyone know of
advantages of one vs  the other.

Thank you.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: substr vs char.substr

Jon K Peck

The older function, substr, is byte oriented while the newer one, char.substr, is character oriented.  That matters if (a) you use any multi-byte character sets (Japanese, Traditional or Simplified Chinese, or Korean) or (b) you use Unicode mode.  In Unicode mode, simple roman characters have the same byte representation as in code page mode, but accented characters and other character sets have a different byte representation.  char.substr will give the same results in Unicode and code page modes, but substr will not.

There is no reason to use the older function unless you are creating transformation syntax that needs to run on SPSS versions prior to 16.

There is a whole family of char.* functions that are character oriented.

HTH,

Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435



From: "<Boris Yanovsky>" <[hidden email]>
To: [hidden email]
Date: 12/03/2009 08:23 AM
Subject: [SPSSX-L] substr vs char.substr
Sent by: "SPSSX(r) Discussion" <[hidden email]>





Hello all,

What really is the difference between SUBSTR and CHAR.SUBSTR string
functions? I have used both in the past, but does anyone know of
advantages of one vs  the other.

Thank you.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD