GitHub
Tests: 12 • Commercial: 2 • Pet projects: 4 • Legacy: 4
Total: 22

.NET Framework

Test
2021

Project Request

ASP.NET MVC • C# • SQL Server
Idea of the project: if someone wants to order a project development, here you can send an application.
Test
2020

ProjectC

ASP.NET MVC • C# • JSON • jQuery
JSON data processing.
Test
2020

Vehicle Maintenance

ASP.NET MVC • VB.NET • JSON
Idea of the project: if someone wants to order a project development, here you can send an application.
Test
2019

Movie Navigator

ASP.NET MVC • VB.NET
Request information about movie from IMDB.
Test
2018

Customers Exchange

ASP.NET MVC • C# • SQL Server
Automated teller machine emulation.
Test
2016

ATM

ASP.NET MVC • C#
Automated teller machine emulation.

.NET Core

Pet project
2022

Mail Daemon

.NET 8 • Console • JSON
Utility to send mails with customizable settings.

Custom

Code
2024

Buns of code

.NET Framework • C# • JavaScript
Code snippets from my projects, ready to use; tiny tests; code examples.

PHP

Test
2024

Mediabox

PHP 8 • Laravel 11 • Vue.js • Composer • SQLite
Test project for media files management.
Test
2020

Loan Castle

PHP • MariaDB
Jums jāizstrādā kāda lielāk projekta prototips. Izstrādājot prototipu, paturiet prātā, ka projektam attīstoties, šo prototipu varētu vajadzēt pilnveidot.
Test
2020

Content Management

PHP • MySQL • AJAX
Создать простой сайт, где будет страница с формой для авторизации и страница для авторизованного пользователя.
Test
2019

Laravel

PHP • Laravel • Vue.js • Composer • SQLite
Izveidot aplikāciju, kura ik pēc noteikta intervāla (60 sekundes) veic ierakstu datubāzē izmantojot Laravel freimworka iebūvēto funkcionalitāti.
Test
2019

Phone Check

PHP • JavaScript • JSON • Docker
Implement application to detect country by phone number.

Frontend

Test
2021

Forex Wall

npm • React
For this exercise, what we need is a simple live wall for tracking currencies.

Business projects

Commercial
2008

Certification Center

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • SQL Server • ADO.NET • Dapper • JavaScript • jQuery • Git
Transport registration and certification services in Latvia, Customer Relationship Management.
Commercial
2000

Amerikas Auto

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • SQL Server • ADO.NET • Entity Framework • JavaScript • jQuery • Git
Car service and spare parts for all USA and European car models, Customer Relationship Management.

Pet projects

Pet project
2023

Geolocation Assistant

.NET 8 • ASP.NET Core • C# • Web API • JSON • Git
Website for determining geolocation by IP or geotagged photo.
Pet project
2008

Web Dynamics

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • Web API • JSON • SQL Server • Dapper • JavaScript • jQuery • SVG • Git
Software development blog. Articles, books, videos, content management.
Pet project
2000

Blackball

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • Web API • JSON • XML • SQL Server • Dapper • JavaScript • jQuery • SVG • Git
My entertainment portal created from scratch.

Good old times

Legacy
2000

DOS Clock

Turbo Pascal • Assembler
Digital clock.
Legacy
2000

BrainOut

Turbo Pascal • Assembler
Tank battle game.
Legacy
1999

Airport Administrator

Turbo Pascal
Курсовая работа в институте.
Legacy
1998

Atomizer

Turbo Pascal • Assembler
Atomizer, aka «Studio2D». Graphic raster editor. AGI is my own «Atomizer Generated Image» file format.

Mediabox

2024 Test

Test project for media files management.

PHP 8 Laravel 11 Vue.js Composer SQLite
Information
Source code
  app
  Http
  .bin
  vite
  lib
  dist
  esm
  node
  lib
  core
  env
  node
  lib
  lib
  lib
  lib
  dist
  lib
  lib
  dist
  es
  lib
  vite
  dist
  node
  dist
  css
  js
  app
  data
  logs
  Unit
  math
  src
  src
  src
  docs
  en
  lib
  src
  src
  Cron
  src
  src
  Core
  ORM
  Spot
  filp
  src
  css
  js
  Util
  src
  src
  src
  src
  psr7
  src
  src
  Core
  Text
  Type
  Xml
  Core
  Text
  Type
  Xml
  src
  Auth
  make
  Bus
  View
  Auth
  Bus
  Http
  Mail
  View
  Auth
  Bus
  Http
  dist
  Http
  Json
  Log
  Mail
  html
  text
  Jobs
  lang
  en
  View
  pint
  pint
  src
  sail
  8.0
  8.1
  8.2
  8.3
  src
  src
  src
  src
  Node
  Util
  Node
  Node
  Node
  Data
  Node
  Node
  Util
  Xml
  src
  src
  src
  docs
  Pass
  src
  Curl
  Test
  src
  Date
  Spl
  lazy
  src
  Cli
  Lang
  List
  src
  src
  lib
  Node
  Expr
  Cast
  Name
  Stmt
  src
  src
  Html
  src
  xml
  src
  src
  src
  Data
  Node
  Html
  css
  js
  Xml
  Util
  src
  src
  src
  src
  src
  Test
  Test
  Math
  Type
  Api
  Rule
  Stub
  Api
  PHPT
  Cli
  Xml
  Util
  PHP
  Xml
  psr
  src
  src
  src
  src
  src
  docs
  src
  log
  src
  src
  psy
  src
  Hoa
  77
  78
  Sudo
  Util
  src
  src
  Map
  Tool
  uuid
  src
  Time
  Guid
  Lazy
  Math
  Dce
  Node
  Time
  Type
  src
  src
  src
  src
  src
  diff
  src
  src
  src
  src
  src
  src
  src
  src
  type
  src
  type
  src
  Test
  CI
  Node
  css
  js
  File
  Test
  Log
  Test
  Smtp
  Auth
  mime
  Part
  Test
  Test
  data
  data
  Test
  Util
  Test
  uid
  css
  js
  Test
  yaml
  Tag
  src
  src
  Css
  Rule
  src
  File
  Util
  voku
  src
  voku
  data
  src
  .env
Root / vendor / voku / portable-ascii
Name
Size
Date created
Date modified
src
25.08.2024 16:05
25.08.2024 16:05
6 KB
25.08.2024 16:05
08.03.2022 19:03
860 bytes
25.08.2024 16:05
08.03.2022 19:03
1 KB
25.08.2024 16:05
08.03.2022 19:03
18 KB
25.08.2024 16:05
08.03.2022 19:03
README.MD

SWUbanner

Build Status Build status codecov.io Codacy Badge Latest Stable Version Total Downloads License Donate to this project using Paypal Donate to this project using Patreon

🔡 Portable ASCII

Description

It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your server.

The benefit of Portable ASCII is that it is easy to use, easy to bundle.

The project based on ...

  • Sean M. Burke's work (https://metacpan.org/pod/Text::Unidecode)
  • Tomaz Solc's work (https://pypi.org/project/Unidecode/)
  • Portable UTF-8 work (https://github.com/voku/portable-utf8)
  • Daniel St. Jules's work (https://github.com/danielstjules/Stringy)
  • Johnny Broadway's work (https://github.com/jbroadway/urlify)
  • and many cherry-picks from "github"-gists and "Stack Overflow"-snippets ...

Index

Alternative

If you like a more Object Oriented Way to edit strings, then you can take a look at voku/Stringy, it's a fork of "danielstjules/Stringy" but it used the "Portable ASCII"-Class and some extra methods.

// Portable ASCII
use voku\helper\ASCII;
ASCII::to_transliterate('déjà σσς iıii'); // 'deja sss iiii'

// voku/Stringy
use Stringy\Stringy as S;
$stringy = S::create('déjà σσς iıii');
$stringy->toTransliterate();              // 'deja sss iiii'

Install "Portable ASCII" via "composer require"

composer require voku/portable-ascii

Why Portable ASCII?

I need ASCII char handling in different classes and before I added this functions into "Portable UTF-8", but this repo is more modular and portable, because it has no dependencies.

Requirements and Recommendations

  • No extensions are required to run this library. Portable ASCII only needs PCRE library that is available by default since PHP 4.2.0 and cannot be disabled since PHP 5.3.0. "\u" modifier support in PCRE for ASCII handling is not a must.
  • PHP 7.0 is the minimum requirement
  • PHP 8.0 is also supported

Usage

Example: ASCII::to_ascii()

  echo ASCII::to_ascii('�Düsseldorf�', 'de');
  
  // will output
  // Duesseldorf

  echo ASCII::to_ascii('�Düsseldorf�', 'en');
  
  // will output
  // Dusseldorf

Portable ASCII | API

The API from the "ASCII"-Class is written as small static methods.

Class methods

charsArray charsArrayWithMultiLanguageValues charsArrayWithOneLanguage charsArrayWithSingleLanguageValues
clean getAllLanguages is_ascii normalize_msword
normalize_whitespace remove_invisible_characters to_ascii to_ascii_remap
to_filename to_slugify to_transliterate

charsArray(bool $replace_extra_symbols): array

Returns an replacement array for ASCII methods.

EXAMPLE: $array = ASCII::charsArray(); var_dump($array['ru']['б']); // 'b'

Parameters:

  • bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>

Return:

  • array

charsArrayWithMultiLanguageValues(bool $replace_extra_symbols): array

Returns an replacement array for ASCII methods with a mix of multiple languages.

EXAMPLE: $array = ASCII::charsArrayWithMultiLanguageValues(); var_dump($array['b']); // ['β', 'б', 'ဗ', 'ბ', 'ب']

Parameters:

  • bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>

Return:

  • array <p>An array of replacements.</p>

charsArrayWithOneLanguage(string $language, bool $replace_extra_symbols, bool $asOrigReplaceArray): array

Returns an replacement array for ASCII methods with one language.

For example, German will map 'ä' to 'ae', while other languages will simply return e.g. 'a'.

EXAMPLE: $array = ASCII::charsArrayWithOneLanguage('ru'); $tmpKey = \array_search('yo', $array['replace']); echo $array['orig'][$tmpKey]; // 'ё'

Parameters:

  • ASCII::* $language [optional] <p>Language of the source string e.g.: en, de_at, or de-ch. (default is 'en') | ASCII::*_LANGUAGE_CODE</p>
  • bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
  • bool $asOrigReplaceArray [optional] <p>TRUE === return {orig: string[], replace: string[]} array</p>

Return:

  • array <p>An array of replacements.</p>

charsArrayWithSingleLanguageValues(bool $replace_extra_symbols, bool $asOrigReplaceArray): array

Returns an replacement array for ASCII methods with multiple languages.

EXAMPLE: $array = ASCII::charsArrayWithSingleLanguageValues(); $tmpKey = \array_search('hnaik', $array['replace']); echo $array['orig'][$tmpKey]; // '၌'

Parameters:

  • bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
  • bool $asOrigReplaceArray [optional] <p>TRUE === return {orig: string[], replace: string[]} array</p>

Return:

  • array <p>An array of replacements.</p>

clean(string $str, bool $normalize_whitespace, bool $keep_non_breaking_space, bool $normalize_msword, bool $remove_invisible_characters): string

Accepts a string and removes all non-UTF-8 characters from it + extras if needed.

Parameters:

  • string $str <p>The string to be sanitized.</p>
  • bool $normalize_whitespace [optional] <p>Set to true, if you need to normalize the whitespace.</p>
  • bool $keep_non_breaking_space [optional] <p>Set to true, to keep non-breaking-spaces, in combination with $normalize_whitespace</p>
  • bool $normalize_msword [optional] <p>Set to true, if you need to normalize MS Word chars e.g.: "…" => "..."</p>
  • bool $remove_invisible_characters [optional] <p>Set to false, if you not want to remove invisible characters e.g.: "\0"</p>

Return:

  • string <p>A clean UTF-8 string.</p>

getAllLanguages(): string[]

Get all languages from the constants "ASCII::.*LANGUAGE_CODE".

Parameters: nothing

Return:

  • string[]

is_ascii(string $str): bool

Checks if a string is 7 bit ASCII.

EXAMPLE: ASCII::is_ascii('白'); // false

Parameters:

  • string $str <p>The string to check.</p>

Return:

  • `bool

    true if it is ASCII
    false otherwise

`

normalize_msword(string $str): string

Returns a string with smart quotes, ellipsis characters, and dashes from Windows-1252 (commonly used in Word documents) replaced by their ASCII equivalents.

EXAMPLE: ASCII::normalize_msword('„Abcdef…”'); // '"Abcdef..."'

Parameters:

  • string $str <p>The string to be normalized.</p>

Return:

  • string <p>A string with normalized characters for commonly used chars in Word documents.</p>

normalize_whitespace(string $str, bool $keepNonBreakingSpace, bool $keepBidiUnicodeControls, bool $normalize_control_characters): string

Normalize the whitespace.

EXAMPLE: ASCII::normalize_whitespace("abc-\xc2\xa0-öäü-\xe2\x80\xaf-\xE2\x80\xAC", true); // "abc-\xc2\xa0-öäü- -"

Parameters:

  • string $str <p>The string to be normalized.</p>
  • bool $keepNonBreakingSpace [optional] <p>Set to true, to keep non-breaking-spaces.</p>
  • bool $keepBidiUnicodeControls [optional] <p>Set to true, to keep non-printable (for the web) bidirectional text chars.</p>
  • bool $normalize_control_characters [optional] <p>Set to true, to convert e.g. LINE-, PARAGRAPH-SEPARATOR with "\n" and LINE TABULATION with "\t".</p>

Return:

  • string <p>A string with normalized whitespace.</p>

remove_invisible_characters(string $str, bool $url_encoded, string $replacement, bool $keep_basic_control_characters): string

Remove invisible characters from a string.

e.g.: This prevents sandwiching null characters between ascii characters, like Java\0script.

copy&past from https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/Common.php

Parameters:

  • string $str
  • bool $url_encoded
  • string $replacement
  • bool $keep_basic_control_characters

Return:

  • string

to_ascii(string $str, string $language, bool $remove_unsupported_chars, bool $replace_extra_symbols, bool $use_transliterate, bool|null $replace_single_chars_only): string

Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed by default. The language or locale of the source string can be supplied for language-specific transliteration in any of the following formats: en, en_GB, or en-GB. For example, passing "de" results in "äöü" mapping to "aeoeue" rather than "aou" as in other languages.

EXAMPLE: ASCII::to_ascii('�Düsseldorf�', 'en'); // Dusseldorf

Parameters:

  • string $str <p>The input string.</p>
  • ASCII::* $language [optional] <p>Language of the source string. (default is 'en') | ASCII::*_LANGUAGE_CODE</p>
  • bool $remove_unsupported_chars [optional] <p>Whether or not to remove the unsupported characters.</p>
  • bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
  • bool $use_transliterate [optional] <p>Use ASCII::to_transliterate() for unknown chars.</p>
  • bool|null $replace_single_chars_only [optional] <p>Single char replacement is better for the performance, but some languages need to replace more then one char at the same time. | NULL === auto-setting, depended on the language</p>

Return:

  • string <p>A string that contains only ASCII characters.</p>

to_ascii_remap(string $str1, string $str2): string[]

WARNING: This method will return broken characters and is only for special cases.

Convert two UTF-8 encoded string to a single-byte strings suitable for functions that need the same string length after the conversion.

The function simply uses (and updates) a tailored dynamic encoding (in/out map parameter) where non-ascii characters are remapped to the range [128-255] in order of appearance.

Parameters:

  • string $str1
  • string $str2

Return:

  • string[]

to_filename(string $str, bool $use_transliterate, string $fallback_char): string

Convert given string to safe filename (and keep string case).

EXAMPLE: ASCII::to_filename('שדגשדג.png', true)); // 'shdgshdg.png'

Parameters:

  • string $str
  • bool $use_transliterate <p>ASCII::to_transliterate() is used by default - unsafe characters are simply replaced with hyphen otherwise.</p>
  • string $fallback_char

Return:

  • string <p>A string that contains only safe characters for a filename.</p>

to_slugify(string $str, string $separator, string $language, string[] $replacements, bool $replace_extra_symbols, bool $use_str_to_lower, bool $use_transliterate): string

Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing remaining non-ASCII and non-alphanumeric characters, and replacing whitespace with $separator. The separator defaults to a single dash, and the string is also converted to lowercase. The language of the source string can also be supplied for language-specific transliteration.

Parameters:

  • string $str
  • string $separator [optional] <p>The string used to replace whitespace.</p>
  • ASCII::* $language [optional] <p>Language of the source string. (default is 'en') | ASCII::*_LANGUAGE_CODE</p>
  • array<string, string> $replacements [optional] <p>A map of replaceable strings.</p>
  • bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
  • bool $use_str_to_lower [optional] <p>Use "string to lower" for the input.</p>
  • bool $use_transliterate [optional] <p>Use ASCII::to_transliterate() for unknown chars.</p>

Return:

  • string <p>A string that has been converted to an URL slug.</p>

to_transliterate(string $str, string|null $unknown, bool $strict): string

Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed unless instructed otherwise.

EXAMPLE: ASCII::to_transliterate('déjà σσς iıii'); // 'deja sss iiii'

Parameters:

  • string $str <p>The input string.</p>
  • string|null $unknown [optional] <p>Character use if character unknown. (default is '?') But you can also use NULL to keep the unknown chars.</p>
  • bool $strict [optional] <p>Use "transliterator_transliterate()" from PHP-Intl

Return:

  • string <p>A String that contains only ASCII characters.</p>

Unit Test

  1. Composer is a prerequisite for running the tests.
composer install
  1. The tests can be executed by running this command from the root directory:
./vendor/bin/phpunit

Support

For support and donations please visit Github | Issues | PayPal | Patreon.

For status updates and release announcements please visit Releases | Twitter | Patreon.

For professional support please contact me.

Thanks

  • Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
  • Thanks to StyleCI for the simple but powerful code style check.
  • Thanks to PHPStan && Psalm for really great Static analysis tools and for discover bugs in the code!

License and Copyright

Released under the MIT License - see LICENSE.txt for details.