

December 12, 2016

TRIM function has no way to covert Double byte character set (DBCS) to Single byte character set (SBCS). Therefore I used MID / LEN functions to remove the first and the last spaces of target DBCS and converted it SBCS smoothly. However, is it any workaround to convert SBCS to DBCS by using Excel functions? I tried to add a pair of leading and trailing spaces on the SBCS but failed.

VIP

April 21, 2015



December 12, 2016

Frans,
I simply used the following formula to remove the first and the last characters of a DBCS string in cell A1
MID(A1,2,LEN(A1)-2)
Phil,
I used my Excel 2013 and checked the character length after ASC converting but found the same number as original DBCS string. It's supposed to have a gap of 2, right? Furthermore, Excel 2013 does not support DBCS function. Do I have other options?


October 5, 2010

Hi Julian,
DBCS is supported in Excel 2013, it says so at the top of the function description, and I've used it in my own Excel 2013.
The number of characters in a string is not related to whether that string is DBCS or SBCS. The difference between DBCS and SBCS is the number of bytes the computer uses to represent the character : 1 for Single Byte CS, 2 for Double Byte CS.
So if I have a DBCS string "MOTH" it is 4 characters and LEN("MOTH") will give an answer of 4. But it uses 8 bytes of memory to store the string.
If we use SBCS and the string is "MOTH" the length of the string is also 4, and only uses 4 bytes of memory for storage.
Using string functions like TRIM and MID have no effect on the underlying character set used to represent the string.
Reference
Cheers
Phil
1 Guest(s)
