Questions tagged [bin2hex]
14 questions
3
votes
2 answers
PHP emoji to unicode not converting more than one emoji appropriately
This function converts emoji to unicode
function emoji_to_unicode($emoji) {
$emoji = mb_convert_encoding($emoji, 'UTF-32', 'UTF-8');
$unicode = strtoupper(preg_replace("/^[0]+/","U+",bin2hex($emoji)));
return $unicode;
}
usage
$var =…

Otávio Barreto
- 1,536
- 3
- 16
- 35
2
votes
2 answers
php - 2 identical string showing different lengths
I am having a problem comparing 2 identical strings. The first string is retrieved from a database and the other hard coded.
The string is { "name":"John", "age":30, "car":null }.
I've first run this code and the database string has a length of 79…

Peter Griffin
- 300
- 5
- 18
1
vote
1 answer
Convert hex to bin in Haskell
I want to convert hex to bin haskell and this is what I did but it seems wrong. Could anyone help please?
bin:: Char -> String
bin'0' = "0000"
bin'1' = "0001"
bin'2' = "0010"
bin'3' = "0011"
bin'4' = "0100"
bin'5' = "0101"
bin'6' = "0110"
bin'7' =…

john do
- 11
- 1
1
vote
1 answer
PHP keep emoji in unicode but also keep text as plain text
I have this function to convert emoji to unicode, but it's also converting text to hex.
How to only convert the emoji and keep text as plain text string?
function emoji_to_unicode($emoji) {
$emoji = mb_convert_encoding($emoji, 'UTF-32',…

Otávio Barreto
- 1,536
- 3
- 16
- 35
1
vote
1 answer
hex value to string of characters
I have a hex number that I get from a bin2hex() call. I need a string representing this number in the format outlined below:
$tmp = bin2hex($foo)
// $tmp is 0x123efd
I need some code that will give me the string "123efd".

user2296342
- 35
- 4
0
votes
1 answer
How to encode data in hexadecimal?
The code:
#0c0f56415445532d413636373231343939
Is: VATES-A66721499 but encoded in hex.
I have made the following attempt:
$hex = bin2hex('VATES-A66721499');
echo $hex;
output:
56415445532d413636373231343939
But I need to get this other…

J. Mick
- 55
- 6
0
votes
1 answer
An alternative in php to the xxd command in linux
I need to convert the bin file to a string in PHP in the same way as the Linux program does.
In linux: xxd -g 1 data.bin and output: 0000000: 02 50 45 10 02 06 54 62 43 20 05 20 11 07 21 12 .PE...TbC . ..!.
In PHP, I tried to use the bin2hex…

Krystian
- 47
- 7
0
votes
0 answers
hashid encryption returning no value in PHP
Was trying to encrypt text:- "Michael Fehr" or "carpet" using hashids, it returns blank.
Code:-
$hashids = new Hashids\Hashids("mysalt");
$hashed_text = $hashids->encode_hex(bin2hex("Michael Fehr"));
echo…

kayos
- 31
- 5
0
votes
0 answers
PHP hexadecimal matrix map
I have hexadecimal content saved inside a string, however I would like to get a value that is located at a specific address (ex. 0xD3)
I have the following code to read the .bin file and show it's content:
$handle = @fopen($file, "r");
if…

João Dessain Saraiva
- 11
- 4
0
votes
1 answer
PHP encoding problem: how to encode base64 encoded uint8 bytes to hex
My problem is that I was some time ago base64 encoding random bytes from openssl sha256 in C (as uint8_t), feeding them into a shell script and using the output.
What I can recreate from my data now is:
Content of…

Mathias A
- 13
- 4
0
votes
1 answer
bin2hex() Cuts off Trailing Zeros
I have a form that inserts items into a MySQL database upon submission. I have decided to create 16 bit IDs for the items using the random_bytes method in PHP so that every time the form submits I already know the ID and don't have to re-query the…

user7412419
- 105
- 7
0
votes
0 answers
PHP Inserting an image from file path into an rtf doc
The goal is to have php edit an rtf file to insert an image from the server by building some rtf code which according to other questions should insert the image:
{\pict\wmetafile8\picw[N]\pich[N]\picwgoal[N]\pichgoal[N] [BYTES]}
…

Ioan Yamakov
- 1
- 1
0
votes
0 answers
RewriteRule for converting hex2bin
Is it possible to convert a hex value within a historical Url back to the de-hexed version (original ordernumber) for the new Url within a RewriteRule?
Assuming: 3830363234 =…

Vismagine
- 53
- 1
- 5
0
votes
1 answer
Check three bytes inside a Hex string in php
I receive an ascii string like this :
�=message :;:-RemoteCommunicationNo version set.%�? ���2?䋹�
I have to decode it to hex and im using bin2hex. I get this data:
…

Fisnik Hajredini
- 111
- 5
- 13