473,803 Members | 4,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get rid of mysterious  char

2 New Member
When I am writing the degree symbol to a text document using the streamwriter it shows up with a Mysterious  in front of it. I know this has something to do with its encoding but I am new to encoding in general and Have no idea how to work it. here is my code

Expand|Select|Wrap|Line Numbers
  1. StreamWriter sw2;
  2. sw2 = File.CreateText("DB\\ioSys.FIL");
  3. string  DegreeC = "°C";
  4.  
  5. IO_file = "t_01_0" + CBA41G1Bus.Text + "_" + StartAddress1 + "_" + temp + "\t" + temp + ".000000\t0\t"+ DegreeC";
  6.  
  7. sw2.WriteLine(IO_file);
  8.  
Any ideas? Thanks
Apr 9 '09 #1
4 9674
oveshot16
2 New Member
In case anyone stumble upon this, after much searching I have found a fix for this problem even thoughI don't know exactly how it works

I changed my code to look like this

Expand|Select|Wrap|Line Numbers
  1. StreamWriter sw2= new StreamWriter("Devices.FIL", true, Encoding.GetEncoding("ISO-8859-15")); 
  2.  
  3. string  DegreeC = "°C"; 
  4.  
  5. IO_file = "t_01_0" + CBA41G1Bus.Text + "_" + StartAddress1 + "_" + temp + "\t" + temp + ".000000\t0\t"+ DegreeC"; 
  6.  
  7. sw2.WriteLine(IO_file); 
  8.  
this code would not work correctly with ASCII, UTF7, UTF32, or its default UTF8

In ASCII it replace the degree symbol with question marks.

Oddly it did work with UNICODE but the program I am making this file for doesn't read it so it was pointless.

this ISO was the only thing that made it all functional
Apr 9 '09 #2
PRR
750 Recognized Expert Contributor
Specifying encoding is a must...speciall y when you need to transfer/share file
Apr 10 '09 #3
sramey
1 New Member
This was awesome, helped me fix a problem I couldn't figure out. Thanks!
Aug 25 '09 #4
nojiratz
1 New Member
Worked for me! Thx for your post!
Feb 22 '16 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3421
by: Viorel | last post by:
For me is a little bit mysterious how work encoding and decoding functions, what is underneath of their calling? Encoding1.GetBytes(string1); in particularly ASCII.GetBytes(string1) Encoding1.GetChars(string1); Encoding1.GetChars(arrayofbytes1);
0
2505
by: SteveS | last post by:
Can anyone help with a mysterious problem that has arisen since 'upgrading' from 8 to 9.2.0.4? The situation is this: Queries that worked fine under 8 are now producing *really* strange results under 9.2.0.4. The queries all involve functions, including built-in functions like NVL. The strangeness is that less than the expected number of rows is returned *or* and ORA-01422 is generated. Here's an example:
2
1779
by: M Wells | last post by:
Hi All, I'm trying to track down a mysterious problem we're experiencing in which updates and inserts to tables in our mssql2k server appear to be 'disappearing.' To explain our situation: We have a web page (written in ASP, if that's relevant) on which we accept enrollment information.
1
2196
by: Bruce W.1 | last post by:
BACKGROUND My ASP.NET app has been running (or rather available) on a server for about 4 months now. The server is at http://www.webhost4life.com/ They don't add cookies to any of the sites they host. The app was created with VS.NET v.7. And the server is running Windows 2000 Advanced Server.
13
2444
by: Max | last post by:
Hi There! I'm having a mysterious error right after I login using Forms Authentication in my ASP.NET app. Below is the error... Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. The exception throws at the code that tries to set a property (String data type) at my Menu user control.
3
2156
by: David Mathog | last post by:
This one is driving me slightly batty. The code in question is buried deep in somebody else's massive package but it boils down to this, two pointers are declared, the first is: char **resname which is part of the "atoms" structure that is passed into the function from the outside. I have not yet found where it is allocated but I'm reasonably sure from other chunks of this code that it was by:
33
2872
by: Martin Jørgensen | last post by:
Hi, In continuation of the thread I made "perhaps a stack problem? Long calculations - strange error?", I think I now got a "stable" error, meaning that the error always seem to come here now (tried: visual studio 2005 + linux/macintosh gcc)... That's a pretty good thing. I think the error still appears using both gcc and visual studio 2005. Everything is standard C (ANSI C ?? I don't know the difference) - but since so many functions...
7
1711
by: Jess | last post by:
Hello, In the appendix of Accelerated C++, there is a declaration statement const char * const * const * cp; The author says the specifiers are "const char" and the declarator is "* const * const * cp". What does this declaration mean? Thanks,
0
9564
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
10548
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...
0
10316
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
10295
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,...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
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
5500
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
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2970
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.