|
See here[^].Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi,
Thanx Abhinav for reply. I tried the CultureInfo class from the link u provided but it doesnt satisfy my requirement.
What I need is a list like
Name CountryCode
AFGHANISTAN AF
ÅLAND ISLANDS AX
ALBANIA AL
Also When I run the code using CultureInfo class
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
Console.WriteLine("DisplayName: {0} \nName: {1} \nEnglishName: {2}", ci.DisplayName, ci.Name, ci.EnglishName);
Console.WriteLine("2-letter code: {0}", ci.TwoLetterISOLanguageName);
}
I get the 3rd entry
DisplayName: Catalan
Name: ca
EnglishName: Catalan
2-letter code: ca
It is showing ca as its country code, while we know that CA is the country code for CANADA. I think this only shows the culture info not the country list with country codes.
My problem is that these country names are different in non-english Windows so I have to get these names from the system instead of hard coding them.
I hope more replies to it.
Best regards,
|
|
|
|
|
Hi,
A list of country names with 3 digit code would also satisfy my need.
This list can also work in my case
Name CountryCode
AFGHANISTAN 004
ALBANIA 008
ALGERIA 012
Regards,
|
|
|
|
|
Try this[^]. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hi,
I have already googled and found nothing usable.
Regards
|
|
|
|
|
Cyber Friend wrote: I have already googled and found nothing usable.
Well you obviously ignored every link that I found for you. Just picking one at random I found all the international two letter country codes.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hi Richard,
Have u read what I have asked in this thread?
I want country names list using C# like
Name CountryCode
AFGHANISTAN AF
ÅLAND ISLANDS AX
ALBANIA AL
Post at least one link in ur next reply which is related to this problem.
Regards,
|
|
|
|
|
|
Hi,
I m lazy? How?
I said "I want country names list using C# like"
So I m looking at ways to get it "using C#".
Plz read my posts before replying to me.
This is a programming forum so I m seeking a programatic solution, The link u provided has already been visited by me.
Regards,
|
|
|
|
|
There is no magic ISO country code class in the framework. you'll need to copy the list into a storage medium (database, text file, xml etc) and write your own code to query it.
|
|
|
|
|
Hi,
Ok I will try to do something for it. Thanx to all of you for your kind participation.
Regards,
|
|
|
|
|
Look, look, I have solved your problem, where can I send my bill???
Countries WebService
Isn't that great, and guess what??? I googled it!!!!, look at this one
List of Culture Codes
and guess what???!!!!! I Googled it too!!!... took me just a few minutes after my last reply, see??? it's very easy and way faster than waiting for some good willing programmers to help you...I want to die like my grandfather- asleep, not like the passengers in his car, screaming!
|
|
|
|
|
Hi,
First of all thanx for googling for me.
Countries WebService
Isn't that great, and guess what??? I googled it!!!!, look at this one
This doesnt satisfy my need because it will always return names in English.
like
<Table> <Name>Afghanistan, Islamic State of</Name> </Table>
I clearly mentioned in one of my above post that I want to get this list from OS System bcoz of Multi linguil aspect of my application. Also I went to the link and invoke GetCountries() method but it only returned the country names, which i think they are getting from some Database.
List of Culture Codes
and guess what???!!!!! I Googled it too!!!
I had already seen this table, but this will be of any use only if I hard code this table in a Database.
BTW thanx for reply.
Regards,
|
|
|
|
|
Then I'm really sorry, but all these sites are ISO based and I don't (I think WE don't) understand what you need, and whatever you need will not be found here and you will have to code it, the 3 numbers you requested were given to you in a link, the 2 letter codes same, I gave you a webservice that gives the information in different ways and even in xml format, the culture codes given to you too... so if nothing helps you out, then I just have to wish you luck and have fun in whatever you're doing I want to die like my grandfather- asleep, not like the passengers in his car, screaming!
|
|
|
|
|
Hi,
I will post some more details tomorow about what I want.
It has some background so I will post a code snippet tomorrow, and then u will be able to know better that What I want. It was my understanding that as it is a basic thing so Microsoft must have provided some Class or method to get this info. Infact MS has provided a Read Only collection of CountryInfo class but problem is that this class is not a documented class, and MS has removed this Read Only Collection of CountryInfo from latest version of the DLL where this class resides. So I thought to get it from some other DLL or Class from .Net framework
Regards,
|
|
|
|
|
Cyber Friend wrote: Have u read what I have asked in this thread?
Yes
Cyber Friend wrote: I want country names list using C# like
And I told you where to find it, I already provided a good list of options, nearly two hours ago. So, if you had followed my advice you would have had a working program by now.
Cyber Friend wrote: Post at least one link in ur next reply which is related to this problem.
Making demands on people who try to help you is considered rude in this forum and may mean that your messages get ignored in the future.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
As I can see, english is not your first language, so perhaps something said in your language that sounds nice and natural translated can be rude for us... anyway... here is a link with the information that you need.
World Atlas and already provided to you
As you will be able to see there, you have A2, A3 and numeric codes for countries, if this doesn't help you and what you want is a full solution for your problem , I'll be more than glad to freelance it for you, as I suspect you'll be using the code for a personal benefit (call it school grades or work) and I want some benefit of it too.I want to die like my grandfather- asleep, not like the passengers in his car, screaming!
|
|
|
|
|
First, let me put your question into other words: Your list should give "US-United Stated, FR-France,etc." on an English windows, "US-Vereinigte Staaten von Amerika, FR-Frankreich,etc." on a German windows etc.
My impression is that this is beyond the grasp of most other people having sent an answer to this thread.
I found a useful link: "How can i get Locale country abbreviation name table of microsoft"[^]
They get a list of all cultures first, then loop through that and get a RegionInfo for each culture - some countries have more than one language, you will have to remove the "duplicates" for your purpose.
RegionInfo.DisplayName shows the country name in the current language.
CultureInfo[] allCultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
foreach (CultureInfo c in allCultures)
{
RegionInfo r = new RegionInfo(c.Name);
Debug.WriteLine(r.Name);
Debug.WriteLine(r.NativeName);
Debug.WriteLine(r.EnglishName);
Debug.WriteLine(r.DisplayName);
Debug.WriteLine(r.ThreeLetterISORegionName);
}
Hope this helps.
|
|
|
|
|
I have a small problem to send a collection or array via socket as we know we can only send byte.
This is a small example of what I wanna do but it is not work:
List<string> list = new List<string>();
list.Add("item1");
list.Add("item1");
sockt.Send(list);
I try this small piece of code but I do not received what I need
String username = Console.ReadLine();
String password = Console.ReadLine();
byte[] msg1 = Encoding.ASCII.GetBytes(username);
byte[] msg2 = Encoding.ASCII.GetBytes(password);
List<ArraySegment<byte>> sendBuffers = new List<ArraySegment<byte>>(2);
sendBuffers.Add(new ArraySegment<byte>(msg1));
sendBuffers.Add(new ArraySegment<byte>(msg2));
client.Send(sendBuffers);
List<ArraySegment<byte>> recvBuffers = new List<ArraySegment<byte>>(2);
byte[] username = new byte[10];
byte[] password = new byte[10];
recvBuffers.Add(new ArraySegment<byte>(username));
recvBuffers.Add(new ArraySegment<byte>(password));
try
{
int bytesReceived = sock.Receive(recvBuffers);
}
catch
{
}
sockt.Received(recvBuffers);
Now if in Client enter
toto as username and 123456 as password
in server I received toto123456 no totoand 123456 seperatly
What can I proceed.
|
|
|
|
|
You need to convert your messages into continuous byte streams, rather than sending multiple messages. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Shouldn't the client wait for a prompt before sending the data? And perhaps include a carriage return?
|
|
|
|
|
Im trying to search for the tag within a text file,when i found it then i want to delete it, can you please help me to delete the tag.
public partial class Display : System.Web.UI.Page
{
StreamReader myread;
string pic;
string readtxt;
string[] heading = new string[1000];
int count;
protected void Page_Load(object sender, EventArgs e)
{
pic = "<img[^<>]+>";
count = pic.Length;
try
{
string mine = Server.UrlDecode(Request.QueryString["mine"]);
readtxt = Server.MapPath(mine);
using (myread = File.OpenText(readtxt))
{
for (int i = 0; i < 500; i++)
{
do
{
if (!myread.EndOfStream)
{
heading[i] = myread.ReadLine();
lbldisplay.Text = String.Join(" ", heading, 0, 500);
}
}
while(heading[i].Contains(pic));
{
lblTry.Text = count.ToString();
heading[i].Remove(200,count);
im having a broblem here
}
}
}
}
catch(Exception ex)
{
lblerror.Text= ex.Message;
}
}
}
}
|
|
|
|
|
You are having problems all over the place there, my friend!
Firstly, never use "Magic numbers" such as
for (int i = 0; i < 500; i++) I see what you are doing, but don't! Instead, loop around on the EndOfStream or the ReadLine.
In actual fact, unless there is a good reason why you want to process the first 500 lines only, consider using File.ReadAllText instead.
Secondly, it looks like you are trying to use a regular expression, but failing.
Thirdly, unless every single line contains the img tag, you loop terminates on the first non match.
What you want to do is (pseudo code):
Allocate a string to hold the file content, and use File.ReadAllText to read the whole thing. This allows for img tags which span lines.
Set up a Regex to hold your img tag seeker.
Use Regex.Replace to replace all instances of the img tag in the file.
Use String.Split to break your file into the various lines, if you need it afterwards.
No loop required!
If you aren't sure how to use any of these, google for File.ReadAllText etc. and you will get instructions!You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
thanx, i managed to follow your instruction,im still having a problem with removing the . my intention is to display the text that remain after removing the image, so im having a proble with that. here is my code.
public partial class Display : System.Web.UI.Page
{
StreamReader myread;
string pic;
string readtxt;
string contents;
string mycontents;
char mychar;
protected void Page_Load(object sender, EventArgs e)
{
mycontents = "<img+>";
Regex myreg = new Regex(mycontents);
try
{
string mine = Server.UrlDecode(Request.QueryString["mine"]);
readtxt = Server.MapPath(mine);
using (myread = File.OpenText(readtxt))
{
if (!myread.EndOfStream)
{
contents = myread.ReadToEnd();
if (myreg.IsMatch(contents))
{
pic = myreg.Replace(mycontents, " ");
//lbldisplay.Text Need to display the contents without the picture
}
}
}
}
catch (Exception ex)
{
lblerror.Text = ex.Message;
}
}
}
}
|
|
|
|
|
First off, when you post code fragments here, use the "code block" widget - it preserves formatting and make it easier to read.
Next, I think you need to read up a bit on Regular expressions! Get a copy of expresso - it helps you to understand what they are doing, and to create them.
Congratulations BTW on putting exception handling in! Well done - it is so easily forgotten.
protected void Page_Load(object sender, EventArgs e)
{
Regex removeImgTag = new Regex(@"\<img.*?(/>|</img>)", RegexOptions.Singleline);
try
{
string mine = Server.UrlDecode(Request.QueryString["mine"]);
string contents = File.ReadAllText(Server.MapPath(mine));
string myContents = removeImgTag.Replace(contents, " ");
lbldisplay.Text = myContents;
}
catch (Exception ex)
{
lblerror.Text = ex.Message;
}
}
Several changes from yours:
1) Don't make variables class scope unless you need them for the whole class - if they are only needed in a method, they should be local to the method.
2) Use sensible names for variables - it helps later when you will be dealing with lots of them!
3) The RegexOptions.SingleLine specifies that matches can cross line boundaries.
4) You don't need to open a file if you just want to read the whole thing - just use the File.ReadAllText method and it will do all the work.
5) You don't need to check if any matches exist - the Replace method will do that for you.
And voila! The HTML no longer has img tags in it.You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|