Subject: Comparing two URL strings

From: mahendrakar s <[email-masked]>
Date: Thu, 19 May 2022 22:23:19 +0530

Hi,
I am facing an issue in comparing two urls (below).
1)  "https://domain.org/v1.0/users/[email-masked]"
2)   "https://domain.org/v1.0/users/test%40user.org"

Comparison of the two strings is failing due to mismatch of '%40'  and (@)
character even though the both urls are the same.
 (gdb) p url
$1 = 0x55d35cfbd1f8 "https://domain.org/v1.0/users/[email-masked]"
(gdb) p graph_url
$2 = 0x7ffd82777240 "https://domain.org/v1.0/users/test%40user.org"

Can you please let me know how to compare these two strings.
One way I could think of is convert both the strings to utf-8 but don't
find an utility function to compare the UTF-8 strings.

Thanks,
Mahendrakar.

---

From: Alan Hodgson <[email-masked]>
Date: Thu, 19 May 2022 10:05:36 -0700

On Thu, 2022-05-19 at 22:23 +0530, mahendrakar s wrote:
> Comparison of the two strings is failing due to mismatch of '%40' 
> and (@) character even though the both urls are the same.
>  (gdb) p url
> One way I could think of is convert both the strings to utf-8 but
> don't find an utility function to compare the UTF-8 strings.
> 

They aren't multi-byte; converting them to UTF-8 wouldn't change
anything. As is, they are in fact different strings, as "URL" is
something only browsers know about.

You probably need to urldecode (or encode) them in your programming
language before storing them.

---

From: mahendrakar s <[email-masked]>
Date: Fri, 20 May 2022 12:45:59 +0530

Thanks Alan.

On Thu, 19 May 2022 at 22:35, Alan Hodgson <[email-masked]> wrote:

> They aren't multi-byte; converting them to UTF-8 wouldn't change anything.
> As is, they are in fact different strings, as "URL" is something only
> browsers know about.
>