Showing posts with label UTF8. Show all posts
Showing posts with label UTF8. Show all posts

Friday, April 1, 2022

TCC, SQLITE, UTF-8 super working (command line tool creation) * pure C is awesome

#include<stdio.h>
#include<stdlib.h>
   #include <sqlite3.h>

 // Compile instructions:
// tcc ctext.c sqlite3.def

// If you use ulaz.txt file saved as utf-8 text file,
// than first line of text must be empty
// just put all select, insert, update and other sqlite commands in ulaz.txt
//line by line
//callback can be modified to write data formated to HTML TABLE, than open it

  static int callback(void *NotUsed, int argc, char **argv, char **azColName){
    int i;
    for(i=0; i<argc; i++){
      printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
    }
    printf("\n");
    return 0;
  }

//int main(int argc, char* argv[])
int main()
{

char const* const fileName = "ulaz.txt";

FILE* file = fopen(fileName, "r");

if(!file){
printf("\n Unable to open : %s ", fileName);
return -1;
}

    char line[500];
    const char algv1[8] = "dora.db";

    //algv1 = "dora.db";

    char str[50];
    FILE *fp;
    fp = fopen("izlaz2.txt", "w");

    if(fp == NULL)
    {
        printf("Error opening file\n");
        exit(1);
    }

    sqlite3 *db;
    char *zErrMsg = 0;
    int rc;

/*  
    if( argc!=3 ){
      fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
      return(1);
    }
*/

    rc = sqlite3_open("dora.db", &db);
    if( rc ){
      fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
      sqlite3_close(db);
      return(1);
    }

/*
    rc = sqlite3_exec(db, "select * from dora where a4 like '%Сремски%'", callback, 0, &zErrMsg);
    if( rc!=SQLITE_OK ){
      fprintf(stderr, "SQL error: %s\n", zErrMsg);
      sqlite3_free(zErrMsg);
    }

*/

//    sqlite3_close(db);

int i=0;
 
while (fgets(line, sizeof(line), file)) {
        printf("%s", line);
//        fputs(str, fp);
        fputs(line, fp);

if (i>0) {
    rc = sqlite3_exec(db, line, callback, 0, &zErrMsg);
    if( rc!=SQLITE_OK ){
      fprintf(stderr, "SQL error: %s\n", zErrMsg);
      sqlite3_free(zErrMsg);
    }
}
    i = i + 1;

    }

    fclose(fp);
    fclose(file);
        sqlite3_close(db);

    return 0;

} 

OR YOU CAN TRY THIS IN GOLANG TOO:


But in GOLANG, you must to install GCC first and:

https://github.com/mattn/go-sqlite3

too many hussle for the same result.

On Windows GCC best installation is MinGW way.

Hundreds and hundreds megabytes for simple peace of code.

On the other hand in TCC you need to install only 1,2 MB and we are in business.

TCC need only dll and def files from main SQLITE web site.

Saturday, May 8, 2021

Unicode @ Bellard TCC as console app finally



TCC @ Windows 10 tips:

#include <fcntl.h>
#include <io.h>
#include <stdio.h>

int main(void) {
    wchar_t str[80];
    int i;
    setmode(_fileno(stdout), _O_U16TEXT);
    setmode(_fileno(stdin), _O_U16TEXT);
    wprintf(L"\x043a\x043e\x0448\x043a\x0430 \nđšđšđ77ђшђшђшђшђ");
    wscanf(L"%ls", str);
    wscanf(L"%d", &i);
    wprintf(L"I am a %ls ,and I have %d year.\n", str, i);
    return 0;
}

//I am very happy about TCC unicode, are you too ?
//Using of: tcc-0.9.27-win64-bin.zip installation


//Lean Mean Coding Machine



I have already managed to set up to use TCC to read from a SQLITE table and write to a text file, but this is much more effective, isn't it ?
You can now use SQLITE in addition to entering and printing text.


And you can try this too:

const wchar_t * wstring = L"some wide string";
wprintf( L"%s\n", wstring );

wchar_t wideChar = 0x1234;
wprintf( L"hex: %04X  char: %c\n", wideChar, wideChar );

Secure your Network with OpenDNS:




Linux tips:


Homebrew Cask extends Homebrew and brings its elegance, simplicity, and speed to the installation and management of GUI macOS applications such as Atom and Google Chrome.

We do this by providing a friendly CLI workflow for the administration of macOS applications distributed as binaries.

$ brew install alfred
==> Downloading https://cachefly.alfredapp.com/Alfred_4.2.1_1187.dmg
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'alfred'.
==> Installing Cask alfred
==> Moving App 'Alfred 4.app' to '/Applications/Alfred 4.app'.
🍺  alfred was successfully installed!
And there we have it. An application installed with one quick command: no clicking, no dragging, no dropping.


$

ls -latr

  1. l - long list  
  2. a - include hidden files 
  3. r - reverse order 
  4. t - sort by time 

  5. $
  6. lspci -k

  7. ++



Monday, October 15, 2018

MySQl, Excel, SQlite

26 slova engleskih
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z

CREATE TABLE excel (
A VARCHAR(40),
B VARCHAR(40),
C VARCHAR(40),
D VARCHAR(40),
E VARCHAR(40),
F VARCHAR(40),
G VARCHAR(40),
H VARCHAR(40),
I VARCHAR(40),
J VARCHAR(40),
K VARCHAR(40),
L VARCHAR(40),
M VARCHAR(40),
N VARCHAR(40),
O VARCHAR(40),
P VARCHAR(40),
Q VARCHAR(40),
R VARCHAR(40),
S VARCHAR(40),
T VARCHAR(40),
U VARCHAR(40),
V VARCHAR(40),
W VARCHAR(40),
X VARCHAR(40),
Y VARCHAR(40),
Z VARCHAR(40)
);

studenti.db
Select * FROM isplata where iznos>0
rb, oznaka, ime, adresa, iznos, broj_racuna


="UPDATE ispalata SET oznaka = 1, ime='"&C2&"', iznos='"&F2&"', broj_racuna='"&E2&"' WHERE rb=1;"

="UPDATE isplata SET oznaka = '"&A2&"', ime='"&C2&"', iznos='"&F2&"', broj_racuna='"&E2&"' WHERE rb=1;"


="UPDATE isplata SET oznaka = '"&A6&"', ime='"&B6&"', iznos='"&G6&"', broj_racuna='"&F6&"', adresa='"&C6&"' WHERE rb=1;"

="UPDATE isplata SET oznaka = '"&A2&"-"&B2&"', ime='"&C2&"', iznos='"&J2&"', broj_racuna='"&H2&"' WHERE rb=1;"



xxx-xxxxxxxx-xx



="INSERT INTO table_name VALUES('"&A1&"','"&B1&"','"&C1&"')"

INSERT INTO tbl_sample(first_name, last_name) VALUES('ime','prezime');


tbl_sample(first_name, last_name

CREATE TABLE IF NOT EXISTS eksel2 (
  id bigint(20) NOT NULL AUTO_INCREMENT,
  c01 text NULL,
  c02 text NULL,
  c03 text NULL,
  c04 text NULL,
  c05 text NULL,
  c06 text NULL,
  c07 text NULL,
  c08 text NULL,
  c09 text NULL,
  c10 text NULL,
  c11 text NULL,
  c12 text NULL,
  PRIMARY KEY (id)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;




INSERT INTO eksel2(c01,c02,c03,c04,c05,c06,c07,c08,c09,c10,c11,c12) VALUES('1','2','3','4','5','6','7','8','9','10','11','12');


SQLite...:


CREATE TABLE `godisnji` (
`rb` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`ime` VARCHAR(40),
`jmbg` VARCHAR(13),
`po_osnovu_doprinosa_na_radu` INTEGER,
`po_osnovu_strucne_spreme` INTEGER,
`po_osnovu_godina_rada` INTEGER,
`po_osnovu_uslova_rada` INTEGER,
`po_osnovu_brige_o_deci` INTEGER,
`broj_maloletnih` INTEGER,
`broj_dece_do_14god` INTEGER,
`adresa` VARCHAR(80),
`telefon` VARCHAR(40),
`napomena` VARCHAR(80),
`datum_donosenja_resenja` VARCHAR(10),
`ukupno` INTEGER
);



CREATE TABLE `putnik` (
`oznaka` TEXT,
`ime` TEXT,
`ADRESA` TEXT,
`RODITELJ` TEXT,
`JMBG` TEXT,
`SKOLA` TEXT,
`GRAD` TEXT,
`relacija` INTEGER,
`naziv_relacije` TEXT,
`prvi_mesec` INTEGER,
`drugi_mesec` INTEGER,
`iznos` REAL,
`broj_racuna` TEXT,
`procenat` INTEGER,
`prvi_iznos` REAL,
`drugi_iznos` REAL
);


CREATE TABLE `osnovna_sredstva` (
`rb` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`naziv` VARCHAR(80),
`inventarski_broj` VARCHAR(20),
`serijski_broj` VARCHAR(80),
`model` VARCHAR(40),
`windows_key` VARCHAR(80),
`opis` VARCHAR(2000),
`sadrzaj` VARCHAR(2000),
`napomena` VARCHAR(200),
`vrednost` REAL,
`amortizacija` REAL,
`datum` VARCHAR(20),
`proizvodjac` VARCHAR(80),
`javna_nabavka` VARCHAR(200),
`revers` VARCHAR(200),
`trebovanje` VARCHAR(200),
`odgovorna_osoba` VARCHAR(60),
`storno` VARCHAR(40)
);



CREATE TABLE `finansije-glavna-knjiga` (
`rb` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`naslov` VARCHAR(80),
    `duguje` REAL,
    `potrazuje` REAL,
    `saldo` REAL,
`konto` VARCHAR(20),
`partner-kupac-dobavljac` VARCHAR(40),
`napomena` VARCHAR(1000),
`datum` VARCHAR(10),
`storno` VARCHAR(10)

);

CREATE TABLE `kontni-plan` (
`rb` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`sifra-konta` VARCHAR(20),
`naziv-konta` VARCHAR(80)
);

CREATE TABLE `partner` (
`rb` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`sifra-partnera` VARCHAR(40),
`naziv-partnera` VARCHAR(80)
);


PRIMER praćenja sopstvenih troškova u prodavnici:






https://sr.wikipedia.org/sr-el/Dvojno_knjigovodstvo

http://informax.serveftp.com/progtools.asp









Sunday, October 14, 2018

Šta je neophodno jednom modernom uredu ili kancelariji

1) ONLYOFFICE https://www.onlyoffice.com/ (from Riga, Latvia)
2) XAMPP
3) VLC
4) Audacity
5) GIMP
6) Inkscape
7) PSPad
8) Notepad ++
9) Visual Studio Code
10) Lazarus IDE
11) Android Studio
12) Java
13) SQLite
14) Postgre
15) GO https://golang.org/
16) Tragac https://beogradsko.blogspot.com/2018/05/aplikacija-tragac-6-je-native-windows.html

 i naravno operativni sistem Windows ili Linux.

Ukoliko i Vi imate da reklamirate neki svoj proizvod ili slične sadržaje, blogove, knjige i sajtove slobodno me kontaktirajte.



**


MORE IMPORTANT TIPS:




IDS protekcija:

Intrusion detection system 
https://en.wikipedia.org/wiki/Intrusion_detection_system

1. Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show the malicious signs -- too many password failures, seeking for exploits, etc.:

http://www.fail2ban.org/wiki/index.php/Main_Page

2. OSSEC scans Microsoft IIS log files and integrity:

https://www.ossec.net/downloads.html

Thursday, August 30, 2018

Pišite zaštićeni tekst u Flat Assembler-u (fasm-u)

; example of simplified Win32 programming using complex macro features

include 'encoding\utf8.inc'
include 'win32wx.inc'

.data

_str du 'Ово је ћирилица Караџића Вука', 0
_str2 du 'hello world1!', 0Dh, 0Ah, 'hello world2!', 0Dh, 0Ah, 'hello world3!', 0Dh, 0Ah

.code

start:
invoke MessageBox, HWND_DESKTOP, _str2, _str, MB_OK
invoke ExitProcess, 0

.end start   



Ono što je super je da možete pisati UTF-8 tekst, ovaj kod nemojte ukucavati direktno u FASM editor, nego u Notepad, Notepad++, Atom, PSPad ili Microsoft Visual Studio Code.

Još jednom da ponovim, nemojte editovati kod u FASMW.exe ili Fresh.exe editorima (IDE-ima za assembler), što će reći, tu samo otvarate kod bez izmena, a editovanje prethodno obavite u PSPad-u na primer.

Ovo je iz razloga što FASM editor podržava samo Ascii unos teksta, ali u njemu možete otvoriti bilo koji enkodirani tekst, pa i UTF-8, samo ga nikad nemojte editovati direktno u FASM, nego u nekom drugom editoru. FASM koristite samo da otvorite .ASM kod i da izkompajlirate kod u EXE izvršni fajl.

Other Tips and Tricks:

https://www.fosshub.com/PSPad.html

https://flatassembler.net/examples.php

https://forum.tuts4you.com/topic/14111-delphi-to-fasm/

https://fresh.flatassembler.net/