Click here to Skip to main content
15,895,370 members
Home / Discussions / C#
   

C#

 
AnswerRe: bypass outlook security message "A programm is trying to access... " Pin
Dave Kreskowiak7-Jan-10 0:36
mveDave Kreskowiak7-Jan-10 0:36 
GeneralRe: bypass outlook security message "A programm is trying to access... " Pin
_T("No name")7-Jan-10 18:31
_T("No name")7-Jan-10 18:31 
GeneralRe: bypass outlook security message "A programm is trying to access... " Pin
Dave Kreskowiak8-Jan-10 1:24
mveDave Kreskowiak8-Jan-10 1:24 
Questioncall Crystal Report problem? [modified] Pin
miss YY6-Jan-10 15:16
miss YY6-Jan-10 15:16 
AnswerRe: call Crystal Report problem? Pin
carlecomm6-Jan-10 19:08
carlecomm6-Jan-10 19:08 
GeneralRe: call Crystal Report problem? Pin
miss YY6-Jan-10 19:14
miss YY6-Jan-10 19:14 
Questionhow to detect which encoding a file is already saved as Pin
califgal6-Jan-10 14:25
califgal6-Jan-10 14:25 
AnswerRe: how to detect which encoding a file is already saved as Pin
Luc Pattyn6-Jan-10 15:04
sitebuilderLuc Pattyn6-Jan-10 15:04 
Hi,

you could open the file for reading and get the first few bytes of the existing file; then check those for the special codes that are present in UTFx encoded files, something along these lines:
if (len>=3 && buffer[0]==0xEF && buffer[1]==0xBB && buffer[2]==0xBF) {
    encoding=65001;     // UTF-8 (1 or more bytes per char)
} else if (len>=2 && buffer[0]==0xFF && buffer[1]==0xFE) {
    encoding=1200;      // Unicode (16-bit little endian)
} else if (len>=2 && buffer[0]==0xFE && buffer[1]==0xFF) {
    encoding=1201;      // Unicode (16-bit big endian)
} else {
    encoding=1252;      // ANSI or Windows-1252 (8-bit)
}


later on, you can create a StreamWriter that takes the encoding into account, by using one of the constructor overloads and an Encoding instance.

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Happy New Year to all.
We hope 2010 soon brings us automatic PRE tags!
Until then, please insert them manually.


AnswerRe: how to detect which encoding a file is already saved as Pin
carlecomm6-Jan-10 19:10
carlecomm6-Jan-10 19:10 
QuestionRe: how to detect which encoding a file is already saved as Pin
califgal8-Jan-10 7:47
califgal8-Jan-10 7:47 
QuestionProblem with the DataGrid Control Pin
Doltsche6-Jan-10 9:51
Doltsche6-Jan-10 9:51 
AnswerRe: Problem with the DataGrid Control Pin
Saksida Bojan6-Jan-10 10:00
Saksida Bojan6-Jan-10 10:00 
GeneralRe: Problem with the DataGrid Control Pin
Doltsche6-Jan-10 11:01
Doltsche6-Jan-10 11:01 
GeneralRe: Problem with the DataGrid Control Pin
Saksida Bojan6-Jan-10 19:28
Saksida Bojan6-Jan-10 19:28 
QuestionException when trying to write in a open Excel file Pin
Priya Prk6-Jan-10 9:03
Priya Prk6-Jan-10 9:03 
AnswerRe: Exception when trying to write in a open Excel file Pin
EliottA6-Jan-10 9:08
EliottA6-Jan-10 9:08 
AnswerRe: Exception when trying to write in a open Excel file Pin
Saksida Bojan6-Jan-10 10:06
Saksida Bojan6-Jan-10 10:06 
AnswerRe: Exception when trying to write in a open Excel file Pin
Dave Kreskowiak6-Jan-10 10:22
mveDave Kreskowiak6-Jan-10 10:22 
QuestionHow use sdf Pin
SajjadZare6-Jan-10 8:51
SajjadZare6-Jan-10 8:51 
AnswerRe: How use sdf Pin
Dimitri Witkowski6-Jan-10 8:55
Dimitri Witkowski6-Jan-10 8:55 
GeneralRe: How use sdf Pin
SajjadZare6-Jan-10 16:53
SajjadZare6-Jan-10 16:53 
GeneralRe: How use sdf Pin
Dimitri Witkowski6-Jan-10 22:12
Dimitri Witkowski6-Jan-10 22:12 
QuestionSubscribing to System Events Pin
bovus6-Jan-10 5:26
bovus6-Jan-10 5:26 
AnswerRe: Subscribing to System Events Pin
bovus6-Jan-10 5:39
bovus6-Jan-10 5:39 
Questioncomponent for datagridview Pin
SajjadZare6-Jan-10 5:14
SajjadZare6-Jan-10 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.