Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3675668
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:00:18+00:00 2026-05-19T03:00:18+00:00

I’m working on a crawler that opens files and parses them and puts the

  • 0

I’m working on a crawler that opens files and parses them and puts the content into a database.

However I’ve had a problem with files that contains odd chars, and I was wondering if there is any simple way to enforce ANSI-encoding of the string before I put it into the database, so to make sure that there is no illegal chars.

The project is written in C#, and the code I use to put stuff into the database is as following:

cmd = new OleDbCommand("INSERT INTO TaIndex (IndexId, IndexTekst, IndexDato, IndexModulId, IndexModul, IndexFilsti) VALUES (?, ?, ?, ?, ?, ?);", conn);
cmd.Parameters.Add("IndexId", OleDbType.Integer).Value = newIdGetter();
cmd.Parameters.Add("IndexTekst", OleDbType.LongVarChar).Value = Text;
cmd.Parameters.Add("IndexDato", OleDbType.Date).Value = DateTime;
cmd.Parameters.Add("IndexModulId", OleDbType.VarChar).Value = ModuleId;
cmd.Parameters.Add("IndexModul", OleDbType.VarChar).Value = Module;
cmd.Parameters.Add("IndexFilsti", OleDbType.VarChar).Value = ((object)FilePath) ?? DBNull.Value;

The problem is with the IndexTekst-field, which comes from the files.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:00:18+00:00Added an answer on May 19, 2026 at 3:00 am

    Well, you could always check that the string can be encoded and then re-decoded to the same value:

    public static bool CanBeRoundTripped(Encoding encoding, string text)
    {
        byte[] bytes = encoding.GetBytes(text);
        string decoded = encoding.GetString(bytes);
        return text == decoded;
    }
    

    Call that on each text field before saving it – and then consider what to do if it fails…

    Is there any way you can change the database schema to accept all Unicode characters? That would be a far more pleasant approach, IMO.

    If you do need to use some sort of ANSI encoding, you should work out exactly which encoding you mean. There are lots of encodings which are generally called “ANSI”. You need to work out which code page you mean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.