macho Posted May 11, 2010 Report Share Posted May 11, 2010 tвtad. man ir liels fails, kur mоkstinвjuma, garumzоmes un visвdi somu, turku u.c. valodu speciвlie burti teiksim a ar punktiтiem, tiek pвrveidoti par иerni. иerтa piemзrs nr. 1 Tauragлs иerтa piemзrs nr. 2 Kriaunш Man vajag visus иerniskos simbolus nahrenizзt. Respektоvi, atstвt tikai a-ю, 0-9 un | (vertikвlв garв svоtra). Pagaidвm proga izskatвs рвdi #include <iostream> #include <fstream> using namespace std; int ir; int main () { char c, str[256]; ifstream is ("FAILZ_viens"); ofstream kautkas ("FAILZ_DIVI"); cout<< "lol"; while (is.good()) // loop while extraction from file is possible { c = is.get(); ir=0; РEIT IR IFS, { ir=1;} if (ir == 0) kautkas << c; } cout<<"hallo"; return 0; } respektоvi "РEIT IR IFS" vietв, man vajag salоdzinвjumu, kas ieиeko vai gadоjumв iehavotais simbols nav huiтa. Kвds zin kвdu вtrвku veidu kв salоdzinврanu ar visiem atпautajiem simboliem? editooorz: nu re, teiksim uzrakstоju if (c > 100) un tв mistiski, daюi ir, daюi nav, te laikam kaut kвda unicode tabula jвieиeko or something. editooorz2: bпin, vajadzзtu kaut kвdu veidu, kв ieиekot vajadzоgo simbolu kodus. bet kв to lai izdara ar lv mоkstinвjumiem/garumzоmзm? oi, lol jвieиeko рite http://www.tamasoft.co.jp/en/general-info/unicode.html editoorz3: nз, tв tabula neder, vai arо, ja der, tad nezinu kв salоdzinвt. Link to comment Share on other sites More sharing options...
macho Posted May 11, 2010 Author Report Share Posted May 11, 2010 bļin, neizskatās, ka mīkstinājuma & garum zīmēm vispār ir tāds kods Link to comment Share on other sites More sharing options...
Norek Posted May 11, 2010 Report Share Posted May 11, 2010 Katram simbolam ir savs kods. Jābūt kādai funkcijai, kurai padodot kodu, atgriež simbolu. C++ nezinu, parakņāšos. Kur ir beefs, kad vajag int(), char() ; int i = 65; cout<<char(i); // It'll print character representing Ascii value of 65 i.e 'A' char a = 'A'; cout<<int(a); // It'll print ASCII value repreented by A, i.e 65 for(i = 65; i <= 90; ++i) cout<<char(i); Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted May 11, 2010 Report Share Posted May 11, 2010 Uztaisi atsevišķu failu, kurā ieraksti visus "labos" simbolus. Pēc tam ielasi no tā faila kaut kādā viltīgā masīvā char str2[256]; pēc tam katram simbolam skaties, vai tas ir starp labajiem simboliem (piemēram ar funckiju strchr) Beefs Link to comment Share on other sites More sharing options...
10BaseT Posted May 11, 2010 Report Share Posted May 11, 2010 (edited) #include <iostream> #include <fstream> using namespace std; int main () { char c, str[256]; ifstream is; is.open ("example.txt"); // open file while (is.good()) // loop while extraction from file is possible { c = is.get(); // get character from file if (is.good()) { if ( ( c >= 'Ā' ) && ( c <= 'Ž' ) || // Ā-Ž ( c >= 'ā' ) && ( c <= 'ž' ) || // ā-ž ( c >= 'A' ) && ( c <= 'Z' ) || // A-Z ( c >= 'a' ) && ( c <= 'z' ) || // a-z ( c >= '|' ) && ( c <= '|' ) || // | ( c >= '0' ) && ( c <= '9' ) ) // 0-9 { cout << c; } } } is.close(); // close file return 0; } Edited May 11, 2010 by 10BaseT Link to comment Share on other sites More sharing options...
macho Posted May 11, 2010 Author Report Share Posted May 11, 2010 lol tas tiešām strādās? rīt noteikti izčekošu Link to comment Share on other sites More sharing options...
Norek Posted May 11, 2010 Report Share Posted May 11, 2010 pārbaudīju php - strādā. man nebija ne prātā, ka stringus var tā pielīdzināt. Link to comment Share on other sites More sharing options...
10BaseT Posted May 11, 2010 Report Share Posted May 11, 2010 #include <iostream> #include <fstream> #include "windows.h" using namespace std; int main () { char c; char d[77] = {'|','0','1','2','3','4','5','6','7','8','9', 'A','a','Ā','ā','B','b','C','c','Č','č','D','d','E','e','Ē','ē','F','f','G', 'g','Ģ','ģ','H','h','I','i','Ī','ī','J','j','K','k','Ķ','ķ','L','l','Ļ','ļ', 'M','m','N','n','Ņ','ņ','O','o','P','p','R','r','S','s','Š','š','T','t','U', 'u','Ū','ū','V','v','Z','z','Ž','ž'}; ifstream is; is.open("example.txt"); while (is.good()) { c = is.get(); if (is.good()) { int i; for(i=0;i<=76;i++) { if(c == d[i]) { SetConsoleCP(1257); SetConsoleOutputCP(1257); printf("%c", c); } } } } printf("\n", c); is.close(); system("pause"); return 0; } Link to comment Share on other sites More sharing options...
Kavacky Posted May 11, 2010 Report Share Posted May 11, 2010 Protams, jo tie ēsskī chari glabājas fiziski kā byte ar atbilstošā simbola skaitlisko vērtību, tāpēc arī salīdzinās pareizi, jo tabula ir sakārtota norm secībā a - z un A - Z. Link to comment Share on other sites More sharing options...
macho Posted May 12, 2010 Author Report Share Posted May 12, 2010 wtf dara šīs divas rindas? SetConsoleCP(1257); SetConsoleOutputCP(1257); p.s. kā tajā masīvā ielikt enteru? '/n' taču nebūs ne? p.p.s. biš dīvaina programma 10baset, bet tā otra ideja par masīvu ir totāli ok. neredzu jēgu vienīgi no if (is.good()) - jo šajā ciklā vienmēr ieies, jo pirms tam ir while is.good() Link to comment Share on other sites More sharing options...
macho Posted May 12, 2010 Author Report Share Posted May 12, 2010 ar printf("%x ", c); esmu konstatējis ka hex kods ENTERam ir a, bet kā ellē ratā lai ar to salīdzina? ok, viss atrisinājās, 0x0000000A un 0x000000D vajadzēja pievienot masīvam p.s. 10baseT, tev kods nedaudz nerullē - masīvā 77 elementi, bet ciklā izbliez cauri 76, labāk izmantot sizeof funkciju. Link to comment Share on other sites More sharing options...
Norek Posted May 12, 2010 Report Share Posted May 12, 2010 Teorētiski gan ir pareizi. Es izmantotu <77, bet tas ir tieši tas pats, kas <=76. 0 (nultais) ir 77-ais elements. < sizeof(d) gan būtu pareizāk, piekrītu. Link to comment Share on other sites More sharing options...
macho Posted May 12, 2010 Author Report Share Posted May 12, 2010 ā, fui, aizmirsu par to 0to šitu. Link to comment Share on other sites More sharing options...
worm Posted May 12, 2010 Report Share Posted May 12, 2010 es gan šito jau macho teicu, bet nu lai arī pārējie zin... ne visi kompilatori satur atbalstu priekš utf-8 burtiem, tāpēc ir jāņem vērā, ka get() komanda var ielasīt vienu baitu vai arī vienu multi-byte charakteri... ir jāskatās pēc definīcijas ko get() atgriež... Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now