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.
Interesting case Julian. Do you have some examples on how you did it? I'm not familiar with DBCS and SBCS so have to guess what this is all about, but maybe can help you when I see what it is and how it's working.
Frans
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?
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
Hi Philip,
Is it possible to type the string "MONTH" using DBCS and SBCS respectively in Excel? If this is the case then LOOKUP or MATCH function can find the corresponding strings as a result?
Regards,
Julian
Hi Julian,
Yes, whether "MONTH" is stored as a double-byte or single-byte character, it still only has 5 characters in the string.
Regards
Phil