|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Truncation of Bytes using LEFT |
« View previous topic :: View next topic » |
Author |
Message
|
chenna.hari |
Posted: Sun Mar 20, 2011 7:50 am Post subject: Truncation of Bytes using LEFT |
|
|
Centurion
Joined: 21 Mar 2009 Posts: 103
|
this is regarding truncation to restricted length using LEFT
we have a requirement to truncate a string to 50 bytes
we have done as below
LEFT(CAST(InputRoot.XMLNSC.inputelement AS BLOB CCSID 1208), 50)
and then CAST to CHAR again.
in Some cases we are getting error as unconvertible character. because we are truncating the bytes, if the input string contains multibyte character, and if we try to truncate it to half of the byte, it is giving error while convert back to Character.
Can any one suggest how to resolve this error? |
|
Back to top |
|
 |
mqjeff |
Posted: Sun Mar 20, 2011 10:14 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Do all your truncating with a character representation.
Use the bytes representation to only check if the length is too long.
Or do the right thing, and change the field to accept 50 characters rather than 50 bytes. |
|
Back to top |
|
 |
rekarm01 |
Posted: Sun Mar 20, 2011 12:43 pm Post subject: Re: Truncation of Bytes using LEFT |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
Or, to truncate bytes, it might help to know that for a well-formed UTF-8 sequence, the first byte of a multi-byte character lies within the range C2..F4, while the remaining bytes lie within the range 80..BF. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|