Created
June 2, 2013 21:28
-
-
Save hoehrmann/5695046 to your computer and use it in GitHub Desktop.
API usage examples for URI comparisons in various languages and environments. Anno 2002, originally http://lists.w3.org/Archives/Public/www-archive/2002Dec/0096.html http://lists.w3.org/Archives/Public/www-archive/2002Dec/0094.html http://lists.w3.org/Archives/Public/www-archive/2002Dec/0095.html http://lists.w3.org/Archives/Public/www-archive/2…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class UriEq | |
{ | |
static void Main(String[] Args) | |
{ | |
Uri uri1 = new Uri("http://www.example.org/%61"); | |
Uri uri2 = new Uri("http://www.example.org/a"); | |
System.Console.WriteLine(uri1.Equals(uri2)); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.URL; | |
public class UriEq | |
{ | |
public static void main(String[] args) | |
{ | |
try | |
{ | |
URL uri1 = new URL("http://www.example.org/%61"); | |
URL uri2 = new URL("http://www.example.org/a"); | |
System.out.println(uri1.equals(uri2)); | |
} | |
catch (Exception e) | |
{ | |
System.err.println(e); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl -w | |
use strict; | |
use warnings; | |
use URI; | |
my $uri1 = URI->new("http://www.example.org/%61"); | |
my $uri2 = URI->new("http://www.example.org/a"); | |
print "equal" if $uri1->eq($uri2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <shlwapi.h> | |
#pragma comment(lib, "shlwapi.lib") | |
int main(void) | |
{ | |
LPCTSTR uri1 = "http://www.example.org/%61"; | |
LPCTSTR uri2 = "http://www.example.org/a"; | |
if (UrlCompare(uri1, uri2, FALSE) == 0) | |
{ | |
printf("equal\n"); | |
} | |
else | |
{ | |
printf("not equal\n"); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment