Forum

Notifications
Clear all

How to convert SBCS to DBCS?

7 Posts
3 Users
0 Reactions
273 Views
(@julian)
Posts: 82
Estimable Member
Topic starter
 

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.

 
Posted : 07/05/2018 9:44 am
(@fravis)
Posts: 337
Reputable Member
 

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

 
Posted : 07/05/2018 10:34 am
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

Hi Julian,

ASC converts DBCS so SBCS

DBCS converts SBCS to DBCS.

Cheers

Phil

 
Posted : 07/05/2018 9:50 pm
(@julian)
Posts: 82
Estimable Member
Topic starter
 

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? 

 
Posted : 10/05/2018 6:15 pm
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

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

Double-Byte Character Sets

Single-Byte Character Sets

Cheers

Phil

 
Posted : 10/05/2018 8:02 pm
(@julian)
Posts: 82
Estimable Member
Topic starter
 

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

 
Posted : 10/05/2018 9:48 pm
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

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

 
Posted : 11/05/2018 2:41 am
Share: