// JWSmythe String Converter (converter.php) // (c) 2018 - JWSmythe - http://jwsmythe.com/tools/converter/ // // This is to convert an arbitrary* string from one type to another. // i.e. bin/ascii // // It's a toy I've wanted to throw together for a while. // // There will be some irrelevant HTML validation errors, due to some possible // invalid characters from the conversion. Those odd characters may be absolutely correct. // In testing, I got stuff like this. It's what was decoded correctly, because it was // decoding something that wasn't the right type. // // Error: Malformed byte sequence: 8a. // At line 61, column 66 // Error: Saw U+0000 in stream. // At line 69, column 67 // // This is publically licensed under the // Creative Commons Attribution 3.0 United States (CC BY 3.0 US) // // This code can be used by anyone. If this code is used, in full // or in part, you must provide a link and the (c) and (cc) notices // above. // // Improvements to this code are welcome. Initiate contact with // us via our contact form on http://jwsmythe.com/ // // We would appreciate, but do not require, that you would notify us // if you choose to use this code in your projects, with your company, // or agency. Such contact will remain confidential. It's nice to // know that someone appreciated it enough to use. // // Projects that people use get more attention and further maintenance. // // http://creativecommons.org/licenses/by/3.0/us/legalcode // // v1.0 30-Dec-2018 // UTF-8 sample characters from: http://www.columbia.edu/~fdc/utf8/ /* Sanskrit: काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम् ॥ Sanskrit (standard transcription): kācaṃ śaknomyattum; nopahinasti mām. Classical Greek: ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει. Greek (monotonic): Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα. Old Irish (Ogham): ᚛᚛ᚉᚑᚅᚔᚉᚉᚔᚋ ᚔᚈᚔ ᚍᚂᚐᚅᚑ ᚅᚔᚋᚌᚓᚅᚐ᚜ Anglo-Saxon (Runes): ᛁᚳ᛫ᛗᚨᚷ᛫ᚷᛚᚨᛋ᛫ᛖᚩᛏᚪᚾ᛫ᚩᚾᛞ᛫ᚻᛁᛏ᛫ᚾᛖ᛫ᚻᛖᚪᚱᛗᛁᚪᚧ᛫ᛗᛖ᛬ English (Braille): ⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑ Old Norse (Runes): ᛖᚴ ᚷᛖᛏ ᛖᛏᛁ ᚧ ᚷᛚᛖᚱ ᛘᚾ ᚦᛖᛋᛋ ᚨᚧ ᚡᛖ ᚱᚧᚨ ᛋᚨᚱ Old Norse (Latin): Ek get etið gler án þess að verða sár. Erzian: Мон ярсан суликадо, ды зыян эйстэнзэ а ули. Bosnian, Montenegrin and Serbian (Cyrillic): Ја могу јести стакло, и то ми не штети. Russian: Я могу есть стекло, оно мне не вредит. Belarusian (Cyrillic): Я магу есці шкло, яно мне не шкодзіць. Belarusian (Lacinka): Ja mahu jeści škło, jano mne ne škodzić. Ukrainian: Я можу їсти скло, і воно мені не зашкодить. Bulgarian: Мога да ям стъкло, то не ми вреди. Georgian: მინას ვჭამ და არა მტკივა. Armenian: Կրնամ ապակի ուտել և ինծի անհանգիստ չըներ։ Turkish (Ottoman): جام ييه بلورم بڭا ضررى طوقونمز Bangla / Bengali: আমি কাঁচ খেতে পারি, তাতে আমার কোনো ক্ষতি হয় না। Kannada: ನನಗೆ ಹಾನಿ ಆಗದೆ, ನಾನು ಗಜನ್ನು ತಿನಬಹುದು Hindi: मैं काँच खा सकता हूँ और मुझे उससे कोई चोट नहीं पहुंचती. Tamil: நான் கண்ணாடி சாப்பிடுவேன், அதனால் எனக்கு ஒரு கேடும் வராது. Telugu: నేను గాజు తినగలను మరియు అలా చేసినా నాకు ఏమి ఇబ్బంది లేదు Sinhalese: මට වීදුරු කෑමට හැකියි. එයින් මට කිසි හානියක් සිදු නොවේ. Arabic(3): أنا قادر على أكل الزجاج و هذا لا يؤلمني. Hebrew(3): אני יכול לאכול זכוכית וזה לא מזיק לי. Yiddish(3): איך קען עסן גלאָז און עס טוט מיר נישט װײ. Burmese: က္ယ္ဝန္တော္၊က္ယ္ဝန္မ မ္ယက္စားနုိင္သည္။ ၎က္ရောင့္ ထိခုိက္မ္ဟု မရ္ဟိပာ။ (9) Vietnamese (nôm) (4): 些 ࣎ 世 咹 水 晶 ও 空 ࣎ 害 咦 Khmer: ខ្ញុំអាចញុំកញ្ចក់បាន ដោយគ្មានបញ្ហារ Lao: ຂອ້ຍກິນແກ້ວໄດ້ໂດຍທີ່ມັນບໍ່ໄດ້ເຮັດໃຫ້ຂອ້ຍເຈັບ. Thai: ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ Mongolian (Cyrillic): Би шил идэй чадна, надад хортой биш Mongolian (Classic) (5): ᠪᠢ ᠰᠢᠯᠢ ᠢᠳᠡᠶᠦ ᠴᠢᠳᠠᠨᠠ ᠂ ᠨᠠᠳᠤᠷ ᠬᠣᠤᠷᠠᠳᠠᠢ ᠪᠢᠰᠢ Nepali: म काँच खान सक्छू र मलाई केहि नी हुन्न् । Tibetan: ཤེལ་སྒོ་ཟ་ནས་ང་ན་གི་མ་རེད། Chinese: 我能吞下玻璃而不伤身体。 Chinese (Traditional): 我能吞下玻璃而不傷身體。 Japanese: 私はガラスを食べられます。それは私を傷つけません。 Korean: 나는 유리를 먹을 수 있어요. 그래도 아프지 않아요 Inuktitut (10): ᐊᓕᒍᖅ ᓂᕆᔭᕌᖓᒃᑯ ᓱᕋᙱᑦᑐᓐᓇᖅᑐᖓ */ // Header, just for my site. include_once("../../header.php"); // Some unnecessary crap. Remove if you'd like. /* ini_set('display_errors', '1'); error_reporting(E_ALL & ~E_NOTICE); ini_set('display_startup_errors', '1'); ini_set('track_errors', '1'); */ $box_height = "10"; $box_width = "60"; mb_regex_encoding('UTF-8'); mb_internal_encoding("UTF-8"); //$in = $_POST['input']; if (!empty($_REQUEST['input'])){ //$in = $_REQUEST['input']; $in = ltrim(rtrim($_REQUEST['input'])); }else{ $in = ''; }; // Sorry for this huge print. It's easier to manage the HTML. // Make any td/td pair it's own line, so they can be moved gracefully. // Fill in empty td/td pair to pad out the table correctly (and valid) // // If you want to auto-sumbit the input field. // onchange='this.form.submit()' // print " "; print "
"; // Footer, just for my site. include_once("../../footer.php"); // ********** FUNCTIONS ********** // function bin2txt_8bit($in){ // We need to strip the spaces, if this is padded data. // Also, remove any other characters, since binary doesn't have anything but 0/1. $in = preg_replace("/[^01]+/","",$in); $in = ltrim(rtrim($in)); $out = ''; $pcs = explode("\n", chunk_split($in,8)); #print "Pieces" . print_r($pcs, TRUE) . ""; foreach ($pcs as $thispc){ if ($thispc != ''){ #print "PC " . bindec($thispc) . "
" . print_r($pcs, TRUE) . ""; foreach ($pcs as $thispc){ #print "ord " . ord($thispc) . "
" . print_r($pcs, TRUE) . ""; foreach ($pcs as $thispc){ //$out .= sprintf("%03d", mb_ord($thispc, "UTF-8")); $out .= mb_ord($thispc, "UTF8"); if($padding == 1){ $out .= " "; }; }; return($out); }; function dec2text($in){ // We need to strip the spaces, if this is padded data. // Also, remove any other characters, since dec doesn't have anything but 0123456789. $in = preg_replace("/[^0-9\ ]+/","",$in); // chr doesn't handle entire strings. It must be by character. $in = ltrim(rtrim($in)); $out = ''; #$pcs = explode("\n", chunk_split($in,3)); $pcs = explode(" ", $in); foreach ($pcs as $thispc){ #if (!empty($thispc)){ #if (is_numeric($thispc)){ // Uncaught TypeError: mb_chr(): Argument #1 ($codepoint) must be of type int, string given #if (is_numeric($thispc)){ $thispc = intval($thispc); $out .= mb_chr($thispc); #}; }; return($out); };