Non-Unicode strings in VB.NET?

I've been reading the MSDN documentation on the System.Char and 
System.String types and they mention Unicode throughout without even 
mentioning non-Unicode versions. How do I get a gool 'ol one-byte char and 
non-Unicode string in .NET?

Thanks,
Alain 


0
Alain
2/11/2010 10:56:21 PM
dotnet.general 306 articles. 0 followers. Follow

6 Replies
1435 Views

Similar Articles

[PageSpeed] 44

> I've been reading the MSDN documentation on the System.Char and 
> System.String types and they mention Unicode throughout without even 
> mentioning non-Unicode versions. How do I get a gool 'ol one-byte char and 
> non-Unicode string in .NET?

You don't.
You can get a byte array, but there is no such thing as "non-Unicode string"


-- 
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

0
Mihai
2/12/2010 5:52:18 AM
Hello,

Some more context would help.

..NET uses only unicode strings. You could use a byte array. If this is for 
interop the conversion can be handled for you (or you could use the 
appropriate methods yourself). System.Text.Encoding could also help etc...

What are you trying to do that requires non unicode strings ?

--
Patrice


"Alain Dekker" <abdekker@NOSPAM.fsmail.net> a �crit dans le message de 
groupe de discussion : #Fuft12qKHA.6064@TK2MSFTNGP02.phx.gbl...
> I've been reading the MSDN documentation on the System.Char and 
> System.String types and they mention Unicode throughout without even 
> mentioning non-Unicode versions. How do I get a gool 'ol one-byte char and 
> non-Unicode string in .NET?
>
> Thanks,
> Alain
>
> 

0
Patrice
2/12/2010 9:31:17 AM
I'm communicating with a legacy app that does not support UNICODE. In fact, 
UNICODE is superfluous for this project. Wish there was a way to turn it 
off, but I know and appreciate why its been done.

After your post I found the System.Encoding.ASCII feature and it does what I 
expect. I presume is is transparently handling the second BYTE of each 
two-BYTE character, but for display purposes its fine.

Many thanks,
Alain

"Patrice" <http://scribe-en.blogspot.com/> wrote in message 
news:epSTiY8qKHA.5736@TK2MSFTNGP05.phx.gbl...
> Hello,
>
> Some more context would help.
>
> .NET uses only unicode strings. You could use a byte array. If this is for 
> interop the conversion can be handled for you (or you could use the 
> appropriate methods yourself). System.Text.Encoding could also help etc...
>
> What are you trying to do that requires non unicode strings ?
>
> --
> Patrice
>
>
> "Alain Dekker" <abdekker@NOSPAM.fsmail.net> a �crit dans le message de 
> groupe de discussion : #Fuft12qKHA.6064@TK2MSFTNGP02.phx.gbl...
>> I've been reading the MSDN documentation on the System.Char and 
>> System.String types and they mention Unicode throughout without even 
>> mentioning non-Unicode versions. How do I get a gool 'ol one-byte char 
>> and non-Unicode string in .NET?
>>
>> Thanks,
>> Alain
>>
>>
> 


0
Alain
2/12/2010 3:25:08 PM
On 10-02-12 16:25, Alain Dekker wrote:
> I'm communicating with a legacy app that does not support UNICODE. In fact,
> UNICODE is superfluous for this project. Wish there was a way to turn it
> off, but I know and appreciate why its been done.
>
> After your post I found the System.Encoding.ASCII feature and it does what I
> expect. I presume is is transparently handling the second BYTE of each
> two-BYTE character, but for display purposes its fine.

Hello Alain,

ASCII is restricted to 7 bits. To get the whole lower byte (i.e. the 
first 256 chars of Unicode) you should use:

   System.Text.Encoding.GetEncoding("ISO-8859-1")

or any other code-set you legacy application likes.

Markus
0
Markus
2/12/2010 9:43:59 PM
On 10-02-12 16:25, Alain Dekker wrote:
> I'm communicating with a legacy app that does not support UNICODE. In fact,
> UNICODE is superfluous for this project. Wish there was a way to turn it
> off, but I know and appreciate why its been done.
>
> After your post I found the System.Encoding.ASCII feature and it does what I
> expect. I presume is is transparently handling the second BYTE of each
> two-BYTE character, but for display purposes its fine.

Hello Alain,

ASCII is restricted to 7 bits. To get the whole lower byte (i.e. the 
first 256 chars of Unicode) you should use:

   System.Text.Encoding.GetEncoding("ISO-8859-1")

or any other code-set your legacy application likes.

Markus
0
Markus
2/12/2010 9:47:34 PM
Thanks Markus!

"Markus Betz" <dd02@arcor.de> wrote in message 
news:4b75cc73$0$6576$9b4e6d93@newsspool3.arcor-online.net...
> On 10-02-12 16:25, Alain Dekker wrote:
>> I'm communicating with a legacy app that does not support UNICODE. In 
>> fact,
>> UNICODE is superfluous for this project. Wish there was a way to turn it
>> off, but I know and appreciate why its been done.
>>
>> After your post I found the System.Encoding.ASCII feature and it does 
>> what I
>> expect. I presume is is transparently handling the second BYTE of each
>> two-BYTE character, but for display purposes its fine.
>
> Hello Alain,
>
> ASCII is restricted to 7 bits. To get the whole lower byte (i.e. the first 
> 256 chars of Unicode) you should use:
>
>   System.Text.Encoding.GetEncoding("ISO-8859-1")
>
> or any other code-set your legacy application likes.
>
> Markus 


0
Alain
2/13/2010 11:34:41 PM
Reply:

Similar Artilces:

Timeout from VB.NET program
I am using VB.NET 2008 and SQL Server 2000. From SQL Enterprise Manager I can do a select and a delete, but inside my VB.NET 2008 program I kept getting a timed out. Like this delete statement: delete from tickdata30min where symbol = 'abc' and sequencenumber = '20100301-0000' Do you know why I can do it from SQL Enterprise Manager but timed out from a program ? Thanks "fniles" <fniles@pfmail.com> wrote in message news:OI0QK8PzKHA.2552@TK2MSFTNGP04.phx.gbl... > I am using VB.NET 2008 and SQL Server 2000. > From SQL Enterprise ...

Creating a field to search and enter non duplicate data
Hello all. I have a team of 15 pople that all work with reference numbers, on occasion a number has to be sent to a different work group. I've created a spreadsheet for them to enter the numbers into, but we have been duplicating numbers. I want to create a field to enter th number into, have the field cross reference the exsting numbers, and if it does not find a match, enter the number and sort the list. I know how to create a custom macro that will accomplish what I want to do, but I'd prefer a static formula if it's possible. A formula can not do waht y...

non
...

XPath from String
Does anyone have an example on using an XPath statement (in VB.NET) where the source XML document is NOT a file, but a 'text' value from SQL Server? Load the text file into an XMLDocument and use XPath from there? "Joe Pannone" <JoePannone@discussions.microsoft.com> wrote in message news:5340B1B7-5737-43A7-870A-E9A850615D91@microsoft.com... > Does anyone have an example on using an XPath statement (in VB.NET) where > the > source XML document is NOT a file, but a 'text' value from SQL Server? Its NOT a text file, its a 'text' value in ...

Problem with Connection String in MS office Chart 11.0
I am trying to add a chart on a form in MS Access. (.mdb) I am using Access 2003. Adding MS office chart to my form, I need to define the connection string. The data I want to use in the chart is stored in the same access database. What should be the value of the connection string.. If "XX" is the name of the table containing the data I need to use to plot the chart, what I should input as value for connection string property and what I should input as value for commandtext property. Thanks a lot for your help... ...

Compare two strings and find longest common sub-string
The problem seems relatively straightward to the human eye but I imagine it's quite difficult to do in VBA without prior knowledge of what the strings contain. If I have two strings like: The quick red fox jumped over the lazy brown cow The quick red fox just stood there How would I compare them and identify "quick red fox" as the longest common sub-string? I suppose I would have to start by reading one of the strings into an array and comparing its elements against the second string? Or somehow use the Filter function to send the matching items to another array? B...

Query a non-MS/non-Active Directory LDAP Server
Hi All, Does anyone know how to query an LDAP server from Access VBA that is not a Microsoft / Active Directory (AD) server? I have found a lot of stuff about how to query AD and have succeeded in doing so. But that does not seem to transfer to the non-MS LDAP server. It gives the error "Automation error" "There is no such object on the server." Thanks, Clifford Bass -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201004/1 Clifford Is there a chance that there...

moving between two open word documents in vb
I have a database of items to order. I've created a Word Template to create a Purchase Order. When I fill a PO page I have to add a new page again which gives me a new document. I want these all as one document. I want to create the first page that summarizes all the P.O.s in the file and then append each PO on this page. Then leave the one document open for the user to save, print, etc. I can see how to append one document to another, but how do I switch between them in VB. I have not found a document name control to use. I create the po page with .Docum...

Non Delivery Strangeness
I rebooted Exchange 2003 SP2 and received the following NonDelivery email on 1/3/2006 for an email sent on12/15/2005. I and other users received a few of these and the server seems to perform normally for the 100's of other emails that are sent and received daily. Thanks, Dan Foxley ---------------------- Your message did not reach some or all of the intended recipients. Subject: Purchasing From Your Site Sent: 12/19/2005 2:05 PM The following recipient(s) could not be reached: smartservice@smartwool.com on 1/3/2006 10:17 AM The e-mail system was unable to deliver the message, but d...

NON TAXABLE Item Setup, What TAX CODE to assign
What is the proper way to set up a non taxable item like a coupon or labor? I was assigning the <not assigned> (RMS dbase Tax ID 0) (But I just read said to delete the <not assigned> tax code. to prevent a runtime error (we have not had yet)) Do I need to setup a Non tax tax code? and add all non tax items to it? PS I have a < > (blank)(RMS Dbase tax id 3) tax code that seems to need to be deleted, RMS assigned it tax code 3. There are currently no items assigned to the < > blank tax id I can not find any guidance in the RMS Help. It seems MS ex...

NDR from non-existent email address
Any user that sends a meeting request to the user in question gets the following responce. Your message did not reach some or all of the intended recipients. I changed the info to the innocent. Subject: test Sent: 8/16/2005 9:01 AM The following recipient(s) could not be reached: Gay, Esse M. on 8/16/2005 9:02 AM The recipient name is not recognized The MTS-ID of the original message is: c=US;a= ;p=XXX;l=XXXXXXX-XXXXXXX MSEXCH:MSExchangeMTA:EXCHANGE:XXXXXX This only happens with meeting invites, regular email goes through just fine. It is jus...

Install Business Protal SDK failed on Visual Studio .Net not detec
Tried to Install Business Protal SDK but failed on "Visual Studio .Net not detected"though I already installed Visual Studio 2005 My environment installed with: SQL 2005 GP 9 BP 3 Visual Studio 2005 ...

Using MFC DAO class libraries with Unicode
Hi I have an application that uses the CDaoDatabase and CDaoRecordset classes. It works fine when I compile it for ANSI, but if I compile for Unicode I get "error LNK2019: unresolved external symbol" messages for the DAO classes. I am guessing that I need a Unicode version of the dao dll, but I do not know what file(s) I need and how to install them I would very much appreciate any help on this Thanks Carlo ...

Non-cash, Non-regular Transactions
Money 2003 SE V11 I have a need to set up transactions, such as Mileage, to keep track of non-cash activities. I currently handle it by setting up Bills & Deposits split into two transactions totalling $0.00. The first is the Category/Subcategory I want to track and the second is a Category/(Non-Cash Offset Subcategory) that I filter out of all reports. This works ok for me. Example: (meaning 23 miles traveled) Mileage:Medical/Dental 23.00 Mileage:Offset Non-cash Transaction -23.00 However, the transaction is not regularly occurring. Yet we are required to ...

mail from non exsiting user accounts
Hi, I have one exchange 2003 cluster server. and the email address configured as user@corp.ho.com. We are not using it for external mails. one of our IBM AIX user is able to send mails to anybody in my exchange server eventhough he is not having mail account in the windows 2003 domain. if u check the ID of the sender u will see that he is also using the same domain name ie @corp.ho.com... How can i stop others who do not having account in exchange to send mails to my domain. thanks BM Uncheck "Anonymous access" from SMTP virtual server properties | Access | Authentication and r...

Pull Data From Non-Default Calendar
Hello, I am running Outlook 2003 and I have a macro that pulls data from the default calendar. I created a new calendar named "Instructor Schedule" which is a subfolder under Calendar. I would like to change the code so that the data is pulled from the new calendar. Currently I am using the following code. Set colCal = objNS.GetDefaultFolder(olFolderCalendar).Items What change would I need to implement to get my desired results? Thanks. Regards, Chris -- Regards, Chris Set colCal = objNS.GetDefaultFolder(olFolderCalendar).Folders.Item("Instructor Sch...

non project time
I am using MSP2007 for several projects en use a resource planning. The problem I have is that 1) the people have 8 hour working days but are not working 8 hours on the project. I can simply change the working time per person (it is different per group) but when I ad vacation as a task (next problem) MSP is not using the 8 hours but the adjusted time. This means that the vacation days are shorter than actual. 2) how can I use the non working time and make it visible in the Gantt Chard, like individual vacation and the non project time per day. 3) when adding vacation in the res...

Ignore deductions linked to Direct Deposit to calc Net Pay
When an employee has a deduction linked to direct deposit and another deduction that is a percentage of net pay (ie. garnishment of wages), the amount of the second deduction is less than it should be because the direct deposit deduction is reducing 'net pay.' Since the direct deposit deduction really IS net pay, other deductions should be based on the net pay before deductions linked to Direct deposit. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree&qu...

finding last non empty cell in a column #3
FYI - The column could be any column not just B -- cparson ----------------------------------------------------------------------- cparsons's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1286 View this thread: http://www.excelforum.com/showthread.php?threadid=26238 ...

Insert Automatic, Non-Updating Date Stamp
I use an Excel invoice to bill clients. Currently I have an Invoice Date field which is populated by the =TODAY() function. That's good. However, if I open the spreadsheet down the road and accidentally recalculate, the Invoice Date field is updated with the current date. That's not so good. Is there a simple macro I can use that Inserts the date when the document is created and then terminates? Something, I guess, that calls the TODAY() function and then pops the resulting date value into the appropriate cell. I know I can just use CTRL+; to insert the date manually but I'm shoo...

Formatting numbers in a string
I'm in the process of creating a form to allow me to more quicklycatalog & caption some photos; and for a novice VB user, I'm doingokay I guess. I have set up fields for the image path, prefix,sequence number, and file type. e.g.Path = C:\MyDocuments\MyPhotos\Vacation\Prefix = ThemeParkSequence = 001File type = .jpgBy concatenating all of these fields, I can have the form pull up theimage file with Me!frmImgFile.Picture = Me!txtPath & Me!txtPrefix & Me!txtSequence & Me!txtFiletype.So far, so good.Then I got to where I wanted to have the form step to the next imagesequ...

Enable Non-Backorderable Items in POs (e.g. automatically cancel)
Enable identifying vendors and/or items to be non-backorderable from vendor. (e.g. automatically cancel non-received items) Many vendors do not backorder items. If an item is ordered and not shipped, it must be reordered. The current system requires the PO to be Edited so unreceived items are cancelled. This is an extra step and one if missed, is bad. For example, when an item is not received it remains in "released" status, which means the PO generator does not suggest a reorder. yet the vendor isn't going to ship. We face stock shortages and lost sales. In a busy environ...

non vba way to print non continuous ranges
Hi, Is there a non vba way to print non continous ranges on the one shee using excel? Specifically, lets say I want to print data from columns A, B, C, G an K down to row 35 in each column. Is there a way I can do that withou manually making them continuous by cutting and pasting each range ont a new sheet? Regards, David Obei -- DavidObei ----------------------------------------------------------------------- DavidObeid's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=223 View this thread: http://www.excelforum.com/showthread.php?threadid=27196 You can h...

.net runtime optimization service error in event viewer
Hi all, After installation of SQL SERVER 2008 R2 on windows server r2 standart editon , in event viewer i saw ".NET Runtime Optimization Service (clr_optimization_v2.0.50727_32) - Failed to compile: C:\Program Files (x86)\Microsoft SQL Server \100\Tools\Binn\VSShell\Common7\Tools\VDT\DataProjects.dll . Error code = 0x8007000b " and ".NET Runtime Optimization Service (clr_optimization_v2.0.50727_32) - Failed to compile: C:\Program Files (x86)\Microsoft SQL Server \100\Tools\Binn\VSShell\Common7\Tools\VDT\DataDesigners.dll . Error code = 0x8007000b "...

How do I count non blank rows only?
This seems so simple but I've spent hours without resolution. In column A, I need to count the number of rows that actually have data in them. If there is no data, I need to keep column A blank. Here's an oversimplied example of my simple list. 1 John Doe 2 Susan Smith 3 Joe Dear In column A now I have =COUNTA($B$2:B64) and that works great until you hit a row with no data. I have tried all these: =IF(G69>0,(=COUNTA($B$2:B69))," ") Also =COUNTIF($B$2:B69,">0") There's got to be an easy way that I'm missing!! HEEE...