Click here to Skip to main content
15,914,160 members
Home / Discussions / C#
   

C#

 
AnswerRe: Reading multiple records from a database Pin
Christian Graus6-Feb-09 14:08
protectorChristian Graus6-Feb-09 14:08 
GeneralRe: Reading multiple records from a database Pin
ferronrsmith6-Feb-09 14:19
ferronrsmith6-Feb-09 14:19 
GeneralRe: Reading multiple records from a database Pin
Christian Graus6-Feb-09 16:31
protectorChristian Graus6-Feb-09 16:31 
GeneralRe: Reading multiple records from a database Pin
ferronrsmith6-Feb-09 16:48
ferronrsmith6-Feb-09 16:48 
GeneralRe: Reading multiple records from a database Pin
Christian Graus6-Feb-09 18:16
protectorChristian Graus6-Feb-09 18:16 
GeneralRe: Reading multiple records from a database Pin
ferronrsmith6-Feb-09 20:22
ferronrsmith6-Feb-09 20:22 
GeneralRe: Reading multiple records from a database Pin
ferronrsmith7-Feb-09 10:21
ferronrsmith7-Feb-09 10:21 
QuestionProblem Replacing Smart Quotes Pin
Aaron Hartley6-Feb-09 13:33
Aaron Hartley6-Feb-09 13:33 
I am trying to write some code that will read the contents of a file (C:\Temp\index.html) and replace any smart quotes (“ and ”) with neutral quotes ("). I can find the quotes if I open the file with 1252 encoding, but the replacement does not work. Also, the quotes are found even though they are showing found as values of hex 201C and 201D even though the smart quotes are hex 93 and 94 if I open the file in a hex editor Confused | :confused: .

using System;
using System.Text;
using System.IO;

namespace EncodingExample
{
    class Program
    {
        static int CharPositions(string data, char[] chars)
        {
            int count = 0;
            int pos = data.IndexOfAny(chars);
            while (pos > -1)
            {
                count++;
                Console.WriteLine("  Position: {0}", String.Format("{0:X}", pos));
                pos = data.IndexOfAny(chars, pos + 1);
            }
            return (count);
        }

        static void Main()
        {
            string srcFile = @"C:\Temp\bosssystems\index.html";

            if (File.Exists(srcFile))
            {
                char[] chars = { '"', '"' };
                char quote = '"';
                string data = File.ReadAllText(srcFile, Encoding.GetEncoding(1252));

                Console.WriteLine("Before Replacement");
                CharPositions(data, chars);

                Console.WriteLine();
                foreach (char c in chars)
                {
                    data.Replace(c, quote);
                    Console.WriteLine("Replacing {0}({1}) for {2}({3})", c, String.Format("{0:X}", (int)c), quote, String.Format("{0:X}", (int)quote));
                }

                Console.WriteLine();
                Console.WriteLine("After Replacement");
                CharPositions(data, chars);

                Console.ReadKey();
            }
        }
    }
}

AnswerRe: Problem Replacing Smart Quotes Pin
Guffa6-Feb-09 14:51
Guffa6-Feb-09 14:51 
QuestionC# Registry Change Event Pin
Michael Fritzius6-Feb-09 12:07
professionalMichael Fritzius6-Feb-09 12:07 
AnswerRe: C# Registry Change Event Pin
Christian Graus6-Feb-09 12:42
protectorChristian Graus6-Feb-09 12:42 
AnswerRe: C# Registry Change Event Pin
cmk6-Feb-09 15:54
cmk6-Feb-09 15:54 
AnswerRe: C# Registry Change Event Pin
Giorgi Dalakishvili6-Feb-09 21:00
mentorGiorgi Dalakishvili6-Feb-09 21:00 
Questionhow to work with an opened text file in list box? Pin
pcsience6-Feb-09 9:57
pcsience6-Feb-09 9:57 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn6-Feb-09 10:12
sitebuilderLuc Pattyn6-Feb-09 10:12 
GeneralRe: how to work with an opened text file in list box? Pin
pcsience7-Feb-09 8:25
pcsience7-Feb-09 8:25 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn7-Feb-09 9:09
sitebuilderLuc Pattyn7-Feb-09 9:09 
QuestionRe: how to work with an opened text file in list box? Pin
pcsience8-Feb-09 8:53
pcsience8-Feb-09 8:53 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn8-Feb-09 9:03
sitebuilderLuc Pattyn8-Feb-09 9:03 
GeneralRe: how to work with an opened text file in list box? Pin
pcsience8-Feb-09 9:42
pcsience8-Feb-09 9:42 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn8-Feb-09 10:04
sitebuilderLuc Pattyn8-Feb-09 10:04 
QuestionRe: how to work with an opened text file in list box? Pin
pcsience9-Feb-09 9:08
pcsience9-Feb-09 9:08 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn9-Feb-09 9:19
sitebuilderLuc Pattyn9-Feb-09 9:19 
QuestionCannot figure out how to get the row I need in a datatable Pin
compninja256-Feb-09 9:49
compninja256-Feb-09 9:49 
AnswerRe: Cannot figure out how to get the row I need in a datatable Pin
Luc Pattyn6-Feb-09 10:03
sitebuilderLuc Pattyn6-Feb-09 10:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.