Search all function cannot work when not selecting 'utf8' encoding - vscode-extensions

Here is my setting.json:
{
"files.autoGuessEncoding": true,
"files.encoding": "cp950"
}
That's weird that the setting above cannot get any result from searching all. (ctrl + alt + F)
After I change the setting to be
{
"files.autoGuessEncoding": true,
"files.encoding": "utf8"
}
then it works well.
I have tested in both Mac OS and Windows. The situation are same.
No matter the encoding of document, since I tried several encoding types , including cp950, big5 ... and so on. Searching all function only works on utf8.
Does anyone encounter this problem? and how to fix it ?
Thanks.

I have found the reason.
The search tool in VS code doesn't support auto detection of encodings.
Please set "files.autoGuessEncoding": false, the problem maybe resolved.

Related

How can I get unbuffered input to a program?

I can't figure out how to get unbuffered input.
I tried:
method get-selection() {
getc();
}
Also tried Term::ReadKey module:
use Term::ReadKey;
method get-selection() {
read-key();
}
But I still have to hit enter before I can capture the input. Couldn't find anything in the docs that might help.
I'm on macOS.
https://docs.raku.org/type/IO::Handle#routine_getc states:
Using getc to get a single keypress from a terminal will only work properly if you've set the terminal to "unbuffered".
For MacOS, a Google search gets me to:
https://apple.stackexchange.com/questions/193138/to-install-unbuffer-in-osx

Problem with Prefix in Discord.js (including .toUpperCase())

Basically, I've been developing a bot for several weeks now using the discord.js library and recently encountered a small but crucial issue. Essentially when I declare my argument, I also made it so that the message content (message.content) would be capitalized using .toUpperCase(). Essentially in doing so regardless of the type of prefix you would enter (symbol wise) it would all be read by the program as valid.
For example only: !help - should work, however if I would enter .help, it would also be read as valid.
In any case, here's the code. I appreciate all the help!
bot.on('message', message =>{
let args = message.content.toUpperCase().substring(PREFIX.length).split(" ");
const sender = message.member;
switch(args[0])
{
case 'HELP':
message.reply("I've sent you some documentation on all the commands that you can use...").then(d_msg => {d_msg.delete(3000); });
message.delete(3000);
const attachment = new Attachment('./UtilityBot_Documentation.txt')
message.author.send('[Education] Bot - Documentation');
message.author.send(attachment);
break;
}
})
The discord.js tutorial covers an extremely similar problem to what you're trying to do. I recommend you check it out. The page I linked in specific is doing a very similar thing to you, but it's worth giving the whole thing a read through if you haven't done so already. In general, I would include the following line just above where you established args.
if (!message.content.startsWith(PREFIX)) return;
What I'm doing here is saying if the message does not start with the prefix, stop running until a new message is sent. I might be missing something, but certainly check out the tutorial. It's really well written.
https://discordjs.guide/creating-your-bot/commands-with-user-input.html#basic-arguments

Issues with video path

TestCafe doesn't recognize ${TEST} for video path.
I'm trying to implement test recording for failed tests in order to see how we could replicate the appeared problem, but the video path isn't recognized even though a similar path pattern works for screenshots.
According to the documentation, this should work but the following warning is displayed:
Warnings (1):
The "${TEST}" path pattern placeholder cannot be applied to the recorded video.
The placeholder was replaced with an empty string.
I created TestRunner.js as shown in https://devexpress.github.io/testcafe/documentation/using-testcafe/programming-interface/runner.html. Then I added
if(runnerOptions.takeVideo === true && runInParallel === 1) {
runner.video(reports.videoPath, {
singleFile: true,
failedOnly: true,
pathPattern: store + '-' + env + '/${TEST}/${DATE}_${TIME}/${USERAGENT}'
})
}
return runner
.src(tests)
.browsers(config.browsers)
.screenshots(reports.screenshotPath, runnerOptions.takeScreenshots,
store + '-' + env + '/${TEST}/${DATE}_${TIME}/${RUN_ID}/${USERAGENT}/step-${FILE_INDEX}')
.concurrency(runInParallel)
.run(runnerOptions.run);
As I said screenshots work fine, but videos don't.
According to this GitHub issue, specifying singleFile: true is the cause. When saving all the failed tests into one recording, the path pattern can't use a single test or fixture identifier to name the file.
The following pattern placeholders resolve to an empty string with a single file:
${TEST_ID}
${TEST_INDEX}
${FIXTURE}
${TEST}
${TEST_ID}
The documentation for the path patterns does mention this restriction for single files, but only in reference to ${TEST_ID} and not the other placeholders.
I've checked the scenario and it works without any "path pattern" issues under Windows 10:
testcafe chrome test.js --video artifacts/videos --video-options pathPattern=${TEST}.mp4
Would you please clarify how you specified the pathPattern video option? In addition, please provide your environment details.

SendKeys() method ignores some characters when sending to a text box

I move my Selenium installation to a new server, since then some tests using logins no longer work.
After investigation, I found that the password field was populated with an incorrect value. Therefore the tests failed.
I'm trying to do the following :
_passWordTextBox.Clear();
_passWordTextBox.SendKeys("!!ä{dasd$352310!!!\\_XY>èà$£<?^^");
Here is how the field is populated after those lines:
The "!" character was the only one missing. It worked on the previous server. Some other suspicious characters (like $ éà<) also worked.
I've looked at locale settings (culture differences) between the servers.
From these characters sent in a Password string:
!"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
All of these worked correctly:
"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ _ abcdefghijklmnopqrstuvwxyz{|}
Only these failed to be sent correctly:
!]^`~
I've also tried in other fields (such as a Description field) and see the same failure.
I've tried to see if the command was sent correctly to the selenium server, but the logs seem to suggest it worked:
08:05:35.850 DEBUG [ReverseProxyHandler.execute] - To upstream: {"value":["!\"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~?"]}
It means that the server receives the command correctly, but for some reason the driver or the server doesn't execute properly.
Try this:
_passWordTextBox.SendKeys(#"!!ä{dasd$352310!!!\\_XY>èà$£<?^^");
Maybe is for the validates from field.
You can try using clipboard:
public static void SendValueFromClipboard(this IWebElement txtField, string value)
{
Clipboard.SetText(value);
txtField.SendKeys(OpenQA.Selenium.Keys.Control + "v");
}
This is written on C#, you will need to rewrite it in language, you are using.
After looking into multiple system settings i discovered that both my piloting and executing machine add the same regional settings (Format : French(Switzerland) , Keyboard : French(Switzerland), and I didn't look any further.
While fiddling around i discovered this setting :
As it turns out , the Language for non-Unicode programs was set to French(Switzerland) on the machine executing the tests. Changing it to English(UK) resolved the problem.
Probably a bug in chromedriver.
Your solution doesn't work for me, since I already have that setting set to English, but here's a solution I found if anyone else's interested.
Just change your keyboard to ENG UK in task bar.

How to get author of a pdf document with mupdf

how can I get metadata of a pdf document(e.g. title, author, creation date etc) by using mupdf library? There is not enough documentation to find out this functionality. Comments are not sufficient, too. Most probably, there is a functionality for this purpose but it is hard to find under these circumstances. The following code is what I have so far.
char info[64];
globals *glo = get_globals(env, thiz);
fz_meta(glo->doc, FZ_META_INFO, info, sizeof(info));
I have used FZ_META_INFO tag, but it doesn't work. I didn't get any info, just empty. I have checked that it has metadata. Any help is appreciated.
EDIT:
Target Android sdk:20
Min Android sdk:15
Mupdf version: 1.6
ndk: r10c
Development OS: Ubuntu 12.04
In what sense 'doesn't work' ? Throws an error ? Crashes ? Are you certain the PDF file you are using has any 'Info' metadata ?
What is the version of MuPDF ? What platform are you using ?
You need to set the relevant key in the buffer you pass to fz_meta before you call fz_mets, I notice you aren't doing that.
See win_main.c at around line 487, after you get past the macro this resolves to
char info[256]
sprintf(info, "Title");
fz_meta(doc, FZ_META_INFO, info, 256);
On return 'info' will contain the metadata associated with the Title key in the dictionary.
When in doubt, build the sample app and follow it in a debugger......
If the proper casting allow to send the key,
this casting is NOT correct to receive back a char*.
Exemple;
Proper casting to send a request
char buff[2048];
strcpy(buff,"CreationDate")
if (fz_meta(ctx,doc,FZ_META_INFO,&buff,2048)) {
buff[0] = 0;
}
Will:
find the key,
convert utf8
then will crash when copyback of the result
Proper casting to receive a request
char buff[2048];
strcpy(buff,"CreationDate")
if (fz_meta(ctx,doc,FZ_META_INFO,buff,2048)) {
buff[0] = 0;
}
Will crash during dict scanning.
looks really like a bug!
I confirm that modifying original source
info = pdf_dict_gets(ctx, info, (char *)ptr);
is the way to go. (even if strange that nobody else find it while writing code, because Meta are useful features frequently used