Description: Description field have much Chinese characters and English characters, in Oracle system, one Chinese characters equal three English characters
Requirement: Get Description substring from first character and substring’s length<240 characters
Hi,
Is the encoding UTF-8? in UTF-8, Chinese character is usually encoded as 3 bytes but not always. So we need to evaluate actual byte length, I think. Can you try the following expression?
yourString.Substring(0,Enumerable.Range(0,maxLimit).Where(Function(i) System.Text.Encoding.GetEncoding("UTF-8").GetBytes(yourString.Substring(0,i)).Length<maxLimit).Max)
If your encoding is not UTF-8, please modify it to your encoding.
Regards,
@Yoichi
Thank you so much for your help, Your solution perfectly solved my problem!
1 Like
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.