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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:03:37+00:00 2026-06-04T14:03:37+00:00

So, my question is fairly simple. I have a string and I want to

  • 0

So, my question is fairly simple. I have a string and I want to be able to use it in urls. Simple, right? The tricky part is, however, I want a custom way of encoding it. You see, my language is full of é, í, ô, ä, ľ,š,č,ť…, you get the idea.

So, let’s say I have a string like this:

Čečenský bojovník sa pobil v košickej väzbe

If I use HttpUtility.EncodeUrl, I get this string:

%c4%8ce%c4%8densk%c3%bd+bojovn%c3%adk+sa+pobil+v+ko%c5%a1ickej+v%c3%a4zbe

However, my desired string would look like this (trying to have as user-friendly urls as possible):

cecensky-bojovnik-sa-pobil-v-kosickej-vazbe

Using the function EncodeUrl isn’t an option then. So, I wrote myself a function to do multiple manipulations to the string, doing exactly what I need.

public static string EncodeForUrl(this string s)
{
    string temp = s.StripDiacritics();  // one custom function
    temp = temp.ToLower();
    temp = temp.Trim();
    temp = temp.Replace(" ", "-");
    return temp;
}

I think it’s obvious what’s going on and it works perfectly fine. Well, except the fact a string is immutable, so there’s quite a lot of unnecessary memory allocations going on.

So finally I got to my question – is there some recommended, more efficient way, of doing this?

  • 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-06-04T14:03:38+00:00Added an answer on June 4, 2026 at 2:03 pm

    After some googling I finally found an answer that satisfied my needs. The way Stackoverflow handles the situation is probably the best.

    How does Stack Overflow generate its SEO-friendly URLs?

    and this for stripping diacritics, even better than my current version

    https://meta.stackexchange.com/questions/7435/non-us-ascii-characters-dropped-from-full-profile-url/7696#7696

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

Sidebar

Related Questions

Fairly simple question: I have an init method on my class that has the
A fairly simple question for which I have a guess, but I can't find
I have a fairly simple question about these 2 templating engines. I'm trying to
I have a fairly simple question: how to take one row of cv::Mat and
I have what I hope is a fairly simple question about using the value
I have a fairly simple question: In Javascript how can I return the boolean
I believe this is a fairly simple question but I have no idea where
I actually have a fairly simple question but I'm unable to find an answer
I have a fairly simple system, and for the purposes of this question there
I have a fairly simple question about natural/surrogate key usage in a well-defined context

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.