473,699 Members | 2,302 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 2519
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
7770
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
8470
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
4796
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
3331
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
1248
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
1135
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
1906
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
2148
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
39281
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
8689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
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
8885
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7752
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
5875
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
4376
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
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.