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 118415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:29:28+00:00 2026-05-11T03:29:28+00:00

There is a very similar question already. One of the solutions uses code like

  • 0

There is a very similar question already. One of the solutions uses code like this one:

string.mb_chars.normalize(:kd).gsub(/[^x00-\x7F]/n, '').to_s 

Which works wonders, until you notice it also removes spaces, dots, dashes, and who knows what else.

I’m not really sure how the first code works, but could it be made to strip only accents? Or at the very least be given a list of chars to preserve? My knowledge of regexps is small, but I tried (to no avail):

/[^\-x00-\x7F]/n # So it would leave the dash alone 

I’m about to do something like this:

string.mb_chars.normalize(:kd).gsub('-', '__DASH__').gsub   (/[^x00-\x7F]/n, '').gsub('__DASH__', '-').to_s 

Atrocious? Yes…

I’ve also tried:

iconv = Iconv.new('UTF-8', 'US-ASCII//TRANSLIT') # Also tried ISO-8859-1 iconv.iconv 'Café' # Throws an error: Iconv::IllegalSequence: 'é' 

Help please?

  • 1 1 Answer
  • 3 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. 2026-05-11T03:29:29+00:00Added an answer on May 11, 2026 at 3:29 am

    it also removes spaces, dots, dashes, and who knows what else.

    It shouldn’t.

    string.mb_chars.normalize(:kd).gsub(/[^x00-\x7F]/n, '').to_s 

    You’ve mistyped, there should be a backslash before the x00, to refer to the NUL character.

    /[^\-x00-\x7F]/n # So it would leave the dash alone 

    You’ve put the ‘-’ between the ‘\’ and the ‘x’, which will break the reference to the null character, and thus break the range.

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

Sidebar

Related Questions

I have a very similar problem to the one described in this question .
I know there have already been questions very similar to this, but I couldn't
I have a question very similar to this one but the answer does not
Preamble: My core question is very similar to this one: How can I write
There is a VERY similar question to mine but in my case I don't
I know there is a very similar question here but I was hoping to
This should be simple, but I am still lost. There is a very similar
The three initialize methods of this class are very, very, very similar. I'd like
Note: There is a very similar question here . Bear with me, however; my
This is similar to a previous question , but the answers there don't satisfy

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.