Regular Expression 써서 다음과 같이 하면 됩니다.

public static string StripTags(string html)
{
    return Regex.Replace(html, @"<(.|\n)*?>", string.Empty);
}

다음의 네임스페이스가 필요합니다.

using System.Text.RegularExpressions;

참고 : http://www.vandamme.com/blog.aspx?id=512&blogid=194

Tag : HTML태그제거, in C#, StripTags

코멘트를 남겨 주세요. (Write your message and submit)

Unix Timestamp와 .NET DateTime 간의 상호변환

Posted 2008/05/09 14:13 by 길버트

Unix Timestamp를 .NET DateTime으로 변환할 때

static DateTime ConvertFromUnixTimestamp(int timestamp)
{
    DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
    return origin.AddSeconds((double)timestamp);
}

.NET DateTime을 Unix Timestamp로 변환할 때

static int ConvertToUnixTimestamp(DateTime date)
{
    DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
    TimeSpan diff = date - origin;
    return (int)Math.Floor(diff.TotalSeconds);
}

참고 : http://codeclimber.net.nz/archive/2007/07/10/Convert-a-Unix-timestamp-to-a-.NET-DateTime.aspx

Tag : .net, C#, datetime, unix timestamp

코멘트를 남겨 주세요. (Write your message and submit)

실버라이트에서도 WebClient 이용해서 쉽게 OpenAPI의 XML 데이터 따위를 읽어올 수 있습니다. (실버라이트에서는 비동기만 지원)

그런데 가끔 UTF-8 등으로 인코딩된 XML 파일을 읽을 때 Result의 Unicode 문자들이 깨져 있는 것을 경험하실 겁니다.

이때의 해결방법은 간단합니다.
WebClient에는 Encoding이란 프로퍼티가 있기 때문입니다.

WebClient wc = new WebClient() { Encoding = Encoding.UTF8 };

또는 클래식한 표현으로는 아래와 같이...

WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;

해주시면 준비완료!

Tag : encoding, Silverlight, UTF-8, WebClient, 글자깨짐, 실버라이트

코멘트를 남겨 주세요. (Write your message and submit)
« PREV : 1 : 2 : 3 : 4 : 5 : ... 178 : NEXT »