[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Have any of you run into this before?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 70
Thread images: 6
File: erre.png (109 KB, 982x894) Image search: [Google]
erre.png
109 KB, 982x894
Windows's Command Prompt apparently can't handle 8 bit integer limiting, signed or unsigned
>>
>>54825665
Use Windows PowerSnail instett.
>>
>>54825682
PowerShell?
>>
>>54825665
thats the point, faggot.
if you dont like it, dont use it.
or is that something your autistic mind cant comprehend because your mommy and daddy babied you until you were in your 30s?
>>
>>54825706
Don't need to sperg out just because I made an observation
>>
>>54825716
so pointing out common knowledge needs attention?
>>
>>54825752
so sperging out over inconsequential bullshit necessary?
>>
>>54825665
Are you using Visual Studio to compile the C code?
>>
>>54825696
powershell is cmdline 2.0 for windows.
microshit didnt want to change their original commandline but knew it was obsolete... so they did the only reasonable thing... create a new commandline and name it powershell.
>>
>>54825920
No, CodeBlocks, I had VS 2015 for a bit, but it was way too bloated for my purposes when I just needed C++ anyway
>>
It's due to the way stdint.h works. int8_t casts to char. If you want accurate output of 8-bit ints, learn to use printf and inttypes.h
>>
>>54825665
>can't handle 8 bit integer limiting, signed or unsigned

WTF are you trying to say?

Or maybe, WTF do you *think* you're trying to say?

I don't think you have any idea what you're showing in that screenshot.
>>
>>54825996
Windows can't output 8-bit ints correctly because it's a shit OS
>>
>>54825996
Literally no different than a Linux snob.
>>
>>54826009

You don't understand streams. And tell me exactly how the OS comes into play here.
>>
>cmd can pipe things
>shift+f7 displays history
>>
>>54826009
Holy shit you are stupid.
>>
>>54826083
shift+f7 doesn't work like that though, only for user entered commands
>>
>>54826041
>>54826116
How much is nutella paying you to shill here?
>>
>>54825665
>fell for the namespace meme
>>
File: OP_is_a_faggot.png (47 KB, 1001x462) Image search: [Google]
OP_is_a_faggot.png
47 KB, 1001x462
>>54825665
>apparently can't handle 8 bit integer limiting, signed or unsigned

I still want to know how you arrived at that wording.

Like, what do you think "integer limiting" is? And how is it relevant to the OS? And how is it that you think your screenshot indicates this?
>>
>>54826247
better than typing std:: every time you need an iostream function
>>
>>54826293
>windows
>>
>>54826314

Not really, no.

>>54826317

Sorry, what are you trying to say? Use your words, Bobby.
>>
File: image.jpg (38 KB, 640x303) Image search: [Google]
image.jpg
38 KB, 640x303
>>54825920
Speaking of Visual Studio, do you see that it's compiling telemetry code into everything built with it.
>>
>>54825665
Congrats anon. Most people aren't brave enough to showcase their ignorance in such a puboic forum.
>>
>>54825946
No.
PowerShell is VBScript replacement.
You use it to run script.
Nobody use PowerShell interactively like cmd thanks to verylongfunctionnamebutithinkpeoplewillunderstandwhenreadingmyscript.
>>
strange though, I'd think the shell would interpret them as separate bytes, so a 2-byte value would be printed as 2 single byte ones so for example, 0x4141 would print AA. But it instead prints the values as integers... Doesn't make sense
>>
File: 1464248246623.jpg (20 KB, 258x245) Image search: [Google]
1464248246623.jpg
20 KB, 258x245
>>54829449
>>
>>54829449
Shell has literally nothing to do with this, dumbass. Neither does virtual terminal. It's your program that outputs single characters in first case, and series of numbers in second case. The same binary will work the game way on linux too, with linux shell and linux virtual terminal.
>>
>>54828300
Ffs, can we give OP a break.
>>
So then why does it enter an infinite loop if I use char instead of uint8_t?
>>
>>54830808
Because char can never be greater than 254
>>
File: 1338869423705[1].png (553 KB, 2560x2489) Image search: [Google]
1338869423705[1].png
553 KB, 2560x2489
>>54830822
>>
>>54829449

> I'd think the shell would interpret them as separate bytes, so a 2-byte value would be printed as 2 single byte ones so for example, 0x4141 would print AA

cout << (char)((n >> 8) & 0xFF) << (char)(n & 0xFF) << endl;
>>
OP, please post Java code for better bait.
/g/ will sure blame Java for that.
Next, some anon will claim C# won't have such problem.
After that, another anon will agree on C# anon with unrelated positive remarks.

/g/ in a nutshell.
>>
>>54831179
>things that literally did not happen
>/g/ in a nutshell
>>
>>54831247
Ironically, it happen >>54816523
>>
>>54831257
Constructive discussion with only few comments not on topic. I wonder if you have some filter that hides everything but shiposts?
>>
>>54826214
C++'s << operator takes as the right hand side a wide variety of types. There are different overloaded functions for different types. For char's (the type that 8bit integers typedef to), it displays it as a character. For int's (16 bit int typedefs to 'short', usually), it displays the integer as a string combination of digits.
There might be a way to obtain a wide stream version of stdio, but your best bet is to try to use utf8 or try to find out precisely how cmd renders unicode (if possible).
>>
>>54831327
>how cmd renders unicode (if possible).

It doesn't. You can copy and paste Unicode, but CMD itself can't output Unicode.

In my opinion, the actual rendering of the buffer is MBCS, not UCS-2 or Unicode. People have argued with me about this, but in my opinion the behavior is consistent with MBCS output. It's only the copy functionality that copies Unicode, and that has nothing to do with what's rendered on-screen aside from getting buffer coordinates.

Here's some example code I have sitting in one of my folders:

// WriteUTF8.cpp : Defines the entry point for the console application.
//

#include <iostream>

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

#include "stdafx.h"

#pragma execution_character_set( "utf-8" )

int wmain(int argc, wchar_t argv[])
{
// All translations courtesy of Google, no accuracy implied.
const wchar_t *Russia = L"Poccия";
const wchar_t *Japan = L"日本国";
const wchar_t *Vietnam = L"Việt Nam";

int oldMode = _setmode(_fileno(stdout), /*_O_U8TEXT*/_O_WTEXT);

std::wcout << Russia << std::endl;
std::wcout << Japan << std::endl;
std::wcout << Vietnam << std::endl;

return 0;
}


i think that originated on some Microsoft employee's blog. He sperged out hardcore and MS fired him, and deleted his blog posts. They were far and away the most informative sources of information on Unicode + Windows CMD.

Here's some relevant stuff for changing output modes in Windows:

#include <io.h>     // for _setmode
#include <fcntl.h> // for _O_WTEXT

...

// Set output mode to UTF-8 so the copyright symbol shows properly.
int oldMode = _setmode(_fileno(stdout), _O_U8TEXT);
ShowUsage();
_setmode(_fileno(stdout), oldMode);



You can experiment with different _O_Xxx values when calling _setmode.
>>
>>54831450
Try chcp 65001
>>
>>54831596

Yeah, play around with that. You'll find that it doesn't actually do anything.

Then again, neither does _setmode...
>>
File: Untitled-3.png (58 KB, 1117x802) Image search: [Google]
Untitled-3.png
58 KB, 1117x802
>>54831726
>>
>>54825955

someone double check this
>>
>>54825955
I think this guy is right
>>
>>54825665
You're an idiot.
uint8_t is typedef'd to char, and std::cout << overload for char prints the corresponding ASCII character to stdout.

Also,
>using namespace std;
Kill yourself.
>>
>>54831752

Yeah, the middle one didn't print correctly. Why? Because it's not really UTF-8.
>>
>>54831918
It's not printed correct because of font issues - not because of unicode support issues.
I can copy it:
const wchar_t   *Russia     = L"Poccия";
const wchar_t *Japan = L"日本国";
const wchar_t *Vietnam = L"Việt Nam";

This was copied from console. Which means console outputted characters correctly and only used wrong font.
>>
cast to a bigger int
>>
>>54829449
Because you're an idiot that doesn't know how programs print things.
>>
>>54830822
you mean 127
Char is signed.
>>
>>54832066
I mean 254.
>>
>>54831934
>It's not printed correct because of font issues - not because of unicode support issues.

Nooooooooooooope. Or to put it another way: WHY do you think there's a font issue? Why is it that you can't select a font with full Unicode support? Here's why: because CMD's display window isn't Unicode.

>This was copied from console. Which means console outputted characters correctly and only used wrong font.

No. People commonly claim this, but the ability to copy means jack shit. There's no magical connection between what's on the screen and the copy buffer. CMD can literally put anything it wants into the buffer. So, what's it do? It looks at the coordinates of what you selected, cross-references that to its internal buffer, and copies that.

The CMD window itself is MBCS.
>>
>>54832098
What encoding is it? It outputs Russian as well Vietnamese letters. There is no encoding save for variations of unicode that have both these characters in them.

>its internal buffer
Its internal buffer is exactly contents of the virtual terminal. Thing you see on screen is only a visual representation of this buffer.
>>
>>54832125
>as well Vietnamese letters

Look into what Vietnamese characters are.

>There is no encoding save for variations of unicode that have both these characters in them.

Sorry, what?

1) "Variations of Unicode"? Unicode is Unicode. Are you trying to talk about code pages?

2) How is that relevant, since as I said, it's MBCS output, not Unicode?

>Thing you see on screen is only a visual representation of this buffer.

...Uh, yeah? That's my point? It's got Unicode (well, probably UCS-2) internally, and displays MBCS.
>>
>>54832159
>Sorry, what?
>1) "Variations of Unicode"? Unicode is Unicode. Are you trying to talk about code pages?

lol
Unicode is the standard.
There are various sets of character encodings that represent texts made out of characters defined by unicode standard as series of octets. Among them are utf8, ucs2le, ucs2be, ucs4.
You don't even know basics, anon.

>2) How is that relevant, since as I said, it's MBCS output, not Unicode?
It is relevant, because since it uses MBCS, it has to work with one particular character encoding. Since you're claiming it's not one of unicode encodings, I'm asking you which one it is - which encoding has both я and ệ in them.

>Look into what Vietnamese characters are.
Done! Very educational. My point still stands.
>>
>>54832216

Dunno what you're lol'ing about, your sentence made zero sense.

>There are various sets of character encodings that represent texts made out of characters defined by unicode standard as series of octets. Among them are utf8, ucs2le, ucs2be, ucs4.
You don't even know basics, anon.

I don't know the basics despite already mentioning UCS-2. Okay.

So, to answer your (poorly worded) question: yet again, it's not fucking Unicoce. It's MBCS. I honestly don't know why you keep asking about Unicode.

>It is relevant, because since it uses MBCS, it has to work with one particular character encoding.

You don't appear to know what MBCS is on Windows. Go read up on it.

>Since you're claiming it's not one of unicode encodings, I'm asking you which one it is

It's MBCS.

I think you're confusing "multi-byte character sets" with MBCS. MBCS on Windows isn't Unicode.

Yes, in general terms Unicode encodings are multi-byte character sets, but Windows MBCS isn't Unicode.
>>
>>54832070
No, you mean 127.
>>
>>54832288
>No, you mean 127.

Retard, the original statement is still true:

>Because char can never be greater than 254

OP's code tested against 254, hence the explanations.

Jesus, if you can't understand the thread well enough to follow this, then you don't belong on /g/.

Here's a tip: next time your nerdy sense tingles and you feel the urge to point out something obvious, stop and ask yourself if you're missing something.
>>
>>54832284
>It's MBCS.
MBCS is not a charater encoding.
When something uses MBCS, it means it uses one of character encodings supported by windows, and they are usually referred to by their code page number.
MBCS implies that one particular character encoding is used. I asked which character encoding it is twice, and you still can't answer.

>I don't know the basics despite already mentioning UCS-2. Okay.
You don't know basics because you got confused by unicode encodings.
Your "Sorry, what?" means that you are clueless.
You still failing to answer my simple question means that you are clueless.
>>
>>54832312
>>Because char can never be greater than 254
Implies that it can be equal to 254, which is just plain untrue.
Also, no, unsigned char CAN be greater than 254, you stupid fucking retard, do you know how numbers work?
The maximum value an unsigned char is 255, and the maximum value of a signed char is 127.

Holy shit, kill yourself you fucking retard.
>>
>>54832351
>Implies that it can be equal to 254
It does not imply that. That's your interpretation of it and you're pretty stupid if you interpret it this way.
>>
>>54828885
Yes, it's a VB replacement, but it's also a shell replacement. Not everything it runs is a script.
>>
>>54832363
No, YOU are fucking stupid for not interpreting it my way. My way is the correct way.
When someone says that x can't be greater than y, then that usually means that x can be smaller or equal to y.
Kill yourself.
>>
>>54832378
I'm sorry for causing you this amount of grief.
It's fine.
I'm sure you can still have a normal life even if you interpret greater sign like this.
>>
>>54832378
> != >=
>>
>>54831905
What's the problem with namespace STD again? It seems like a lot of arrogance communing of thinking you're doing any better by doing a little extra work
>>
>>54834709
Fucking autocorrection
>>
>>54832375
>a shell replacement
Such as ?

Here in cmd
dir /s /b


Here in PowerShell
Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName
gci -r | select -exp FullName

Tell me how many of you gonna type the whole shit just to view current directory under certain sorted format.
Thread replies: 70
Thread images: 6

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.