473,748 Members | 5,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Byte string to Unicode & vice versa

Private Function BStr2UStr(BStr)
'Byte string to Unicode string conversion
Dim lngLoop
BStr2UStr = ""
For lngLoop = 1 to LenB(BStr)
BStr2UStr = BStr2UStr & Chr(AscB(MidB(B Str,lngLoop,1)) )
Next
End Function

Private Function UStr2Bstr(UStr)
'Unicode string to Byte string conversion
Dim lngLoop
Dim strChar
UStr2Bstr = ""
For lngLoop = 1 to Len(UStr)
strChar = Mid(UStr, lngLoop, 1)
UStr2Bstr = UStr2Bstr & ChrB(AscB(strCh ar))
Next
End Function

Is there an alternative method (easy & efficient) way of writing the
code for converting Byte string to Unicode & vice versa for the code
shown above?

Your help is kindly appreciated.

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***
Apr 27 '06 #1
1 2523
I did the improvement:

Function getString(Strin gBin)

getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(S tringBin,intCou nt,1)))
Next

End Function

Function getByte(ByteBin )

getByte =""
For intCount = 1 to LenB(ByteBin)
getByte = getByte & chrB(AscB(Mid(S tringBin,intCou nt,1)))
Next

End Function

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***
Apr 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7772
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a DB and display it onscreen. No matter which way I open the file, convert it to Unicode/leave it as is or what ever, I see all single bytes ok, but double bytes become 2 seperate single bytes. Surely there is an easy way to convert these mixed...
3
8476
by: mailar | last post by:
HI, Can anyone tell me how is a multi_byte to single byte and vice versa conversion done in DB2. It would be great even if someone can tell me how Oracle does it? Oracle already has functions called to_single_byte and to_multi_byte which convert a given multi byte character to single byte and vice versa respectively. thanks in advance mailar
43
4807
by: Bill Cunningham | last post by:
I've been reading the C standard online and I'm puzzled as to what multibyte chars are. Wide chars I believe would be characters for languages such as cantonese or Japanese. I know the ASCII character set specifies that each character such as 'b' or 'B' is an 8 bit character. So what's a multibyte character? Also how would you use the function parameter main (char argc, char **argv) if that's correct? Bill
5
3335
by: srikant | last post by:
I am writing a client in C# that needs to communicate over the network to a legacy C++ application that uses Unicode strings. I realize that C# strings are already in Unicode, however, how do I account for the network order transformation. Can I simply do the equivalent of string = "hello world"; // this is a unicode strings (2 bytes per char) bytes buffer = UnicodeEncoding.GetBytes(str); myNetworkStream.Write(buffer, 0, buffer.Length); ...
2
1253
by: crater | last post by:
I need to convert a String to a Byte array and vice versa. Can someone nudge me in the right direction please?
3
1139
by: Lau Lei Cheong | last post by:
Hello, I'm trying to write a converter for converting between Big5 and UTF-8, but I want to make sure a few facts before writing. 1) I know that by default .NET store string in unicode. Would there be any problem if I store Big5 characters in the string? Or could I set the codepage setting for individual string? 2) There are basically three types of Unicode scheme - UTF-7, UTF-8 and
9
1910
by: Pohihihi | last post by:
How can I change object returned from database to a byte array e.g. byte b = row; also how can I save a byte to database row?
16
2153
by: Hugh Janus | last post by:
Hi all, I am using the below functions in order to convert strings to bytes and vice versa. I totally ans shamefully stole these functions from this group btw! Anyway, they work great but as sooooo slow. Anyone know how I can speed this functions up? I basically need to convert a byte to string, perform a function on each 'section' of the string, then reconvert it to a byte. The slow part is the conversion to and from byte, not the...
6
39286
yabansu
by: yabansu | last post by:
Hi all, I think most of you probably know the two .NET framework functions, namely Encoding.GetBytes(string) and Encoding.GetString(byte), to convert string into byte array and vice versa. Now, I want to do the same thing in pure(unmanaged) C++. I searched the Internet but could not find any satisfactory solutions. I am really in need of help! Is there anyone to explain how I can implement these functions by not using .NET library? ...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.