Page 1 of 1

replacing a part of unicode chinese string, with a string

Posted: Fri Mar 19, 2010 2:50 am
by sendmkpk
hi,

the string is "注意:这张订单取代了我们之前的订单#xxxxxxxxx。 请在发票中注明新的" we have to replace xxxxxxxxx with the coressponding key column. like this

注意:这张订单取代了我们之前的订单#BKL2345001。 请在发票中注明新的|
, this key colunm value will change for each row.

currently i am using Convert('xxxxxxxxxx', Xfm_DuplicateCAAPS_IN.PORDNUMB,Xfm_DuplicateCAAPS_IN.Chinese_text)
but, the output i am getting is
注意:这张订单取代了我们之前的订单#BBBBBBBBBB。 请在发票中注明新的
instead of
注意:这张订单取代了我们之前的订单#BKL2345001。 请在发票中注明新的|
and the datatype is varchar Unicode

thnx

Posted: Fri Mar 19, 2010 3:01 am
by ArndW
The convert function works on a single character, not a string and won't work for you in this case. You might use this:

Code: Select all

svKeyPosition  INDEX(Xfm_DuplicateCAAPS_IN.Chinese_text,'xxxxxxxxxx')
NewString[svKeyPosition,10]=Xfm_DuplicateCAAPS_IN.PORDNUMB

Posted: Fri Mar 19, 2010 3:16 am
by sendmkpk
ArndW wrote:The convert function works on a single character, not a string and won't work for you in this case. You might use this:

Code: Select all

svKeyPosition  INDEX(Xfm_DuplicateCAAPS_IN.Chinese_text,'xxxxxxxxxx')
NewString[svKeyPosition,10]=Xfm_DuplicateCAAPS_IN.PORDNUMB
great,

i am still did not understand what to do with index function, can anyone help me with the exact code. i will be thankful.

Posted: Fri Mar 19, 2010 5:16 am
by ArndW
I just realized that I cut-and-pasted an incorrect line 2. The first line is a stage variable that is an integer which gives the starting position of the substring. The second line should be:

Code: Select all

IF svKeyPosition THEN Xfm_DuplicateCAAPS_IN.Chinese_text[1,svKeyPosition-1]:Xfm_DuplicateCAAPS_IN.PORDNUMB:Xfm_DuplicateCAAPS_IN.Chinese_text[svKeyPosition+10,9999] ELSE Xfm_DuplicateCAAPS_IN.Chinese_text

Posted: Fri Mar 19, 2010 5:38 am
by ray.wurlod
Search out the parallel version of Ereplace() that was posted on DSXchange. Use this instead of Convert() which, as Arnd noted, only operates on one character.