The Situation: I'm trying to create this little program to store short messages,notes, etc.. in alert windows in order just to display them simply clicking the .vbs
file.
The Issue: Everything perfectly works exactly how I want, except when I write a message with accented characters in the DOS window which runs the compiled progam (i'm using Dev-C++).
All the accented characters are displayed correctly, but when I write them into the notepad (using fprintf
) all the accented characters become other characters (such as "•…Šss—" ).
Could somebody help me? Is there a c++ function to translate the accented characters in a way notepad can understand correctly?
The Code:
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<locale.h>
int main () {
setlocale (LC_ALL,"UTF8");
FILE *puntafile;
char c, nome[30];
//Choosing file name
printf("Insert file name (Max 25 characters): ");
gets(nome);
while(strlen(nome) > 25)
{
printf("Too much long name!\n");
printf("Insert file name (Max 25 characters): ");
gets(nome);
}
//creation file name .vbs
char est[4];
strcpy (est,".vbs");
strcat (nome,est);
char testo[100];
//create the empty file
puntafile = fopen(nome,"w+");
//Insert the message
printf("Insert the note text (Max 100 characters): ");
gets(testo);
while(strlen(testo) > 100)
{
printf("Too much long text!\n");
printf("Insert the note text (Max 100 characters): ");
gets(testo);
}
//writing in the file...
char note[150];
//start text
strcpy(note,"msgbox \"");
//add the note text
strcat(note,testo);
//ending text
char closing[20];
strcpy(closing,"\" , \"6\" , \"Note\"");
strcat(note,closing);
//writing all in the .vbs file
fprintf(puntafile,"%s",note);
//end and close
printf("Note created!\n");
fclose(puntafile);
system("PAUSE");
}