How can I search for a keyword with special characters in Google Search?

Write it out:

-f: perldoc -f -X. If no file name is specified (as is the case here) checks if $_ contains the name of a plain file

>: Checks if the RHS is greater than the LHS

@+: In scalar context, returns the number of elements in @+

?: the conditional operator

*<: The glob for main::<

.: String concatenation operator

-&'_: Invokes a subroutine main::_. FYI, ' is the perl4 style package name separator. Try perl -MHTML'Template -e 1.

: : Continuing with conditional operator

$# : The output format for printed numbers

/ : Division operator

%! : %ERRNO; see perldoc perlvar

So, it is not impossible to understand if you put a little effort into it. Clearly, this is not how anyone should write programs, but there some benefit from people pushing the boundaries.

beginner – Count characters, words, and lines in files (wc in rust)

I wrote a barebones version of wc in rust. wc is a program that counts the number of characters, words, and lines in a file and outputs those values to the command line. Here is an example of the output:

   9   25  246 Cargo.toml
  52  163 1284 src/main.rs
  61  188 1530 total

My version currently lacks the proper output alignment, and it doesn’t print the total (it also lacks the command line options, and it panics when fed a directory). But I would like to get some feedback before I go any further.

use std::env;
use std::fs::read_to_string;

struct InputFile {
    words: u32,
    lines: u32,
    characters: u32,
    name: String,
}

impl InputFile {
    fn new(name: &String) -> Self {
        let content = read_to_string(name).unwrap();
        let (mut characters, mut words, mut lines) = (0, 0, 0);
        let mut spaced: bool = false;
        for c in content.chars() {
            if c as u8 != 0 {
                characters += 1;
            }
            if c != ' ' && c != 'n' {
                spaced = false
            }
            if c == 'n' {
                lines += 1;
                if !spaced {
                    words += 1;
                    spaced = true;
                }
            }
            if c == ' ' && !spaced {
                words += 1;
                spaced = true;
            }
        }
        Self { lines, words, characters, name: name.to_string() }
    }
}

impl std::fmt::Display for InputFile {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{} {} {} {}",
            self.lines, self.words, self.characters, self.name
        )
    }
}

fn main() {
    let files: Vec<String> = env::args().collect();
    for f in &files(1..) {
        println!("{}", InputFile::new(f));
    }
}

On Windows, PowerShell misinterprets non-ASCII characters in mosquitto_sub output

Problem:

While the mosquitto_sub man page makes no mention of character encoding as of this writing, it seems that on Windows mosquitto_sub exhibits nonstandard behavior in that it uses the system’s active ANSI code page to encode its string output rather than the OEM code page that console applications are expected to use.(1)

There also appears to be no option that would allow you to specify what encoding to use.

PowerShell decodes output from external applications into .NET strings, based on the encoding stored in (Console)::OutputEncoding, which defaults to the OEM code page. Therefore, when it sees the ANSI byte representation of character é, 0xe9, in the output, it interprets it as the OEM representation, where it represents character Θ (the assumption is that the active ANSI code page is Windows-1252, and the active OEM code page IBM437, as is the case in US-English systems, for instance).

You can verify this as follows:

# 0xe9 is "é" in the (Windows-1252) ANSI code page, and coincides with *Unicode* code point
# U+00E9; in the (IBM437) OEM code page, 0xe9 represents "Θ".
PS> $oemEnc = (System.Text.Encoding)::GetEncoding((int) (Get-ItemPropertyValue HKLM:SYSTEMCurrentControlSetControlNlsCodePage OEMCP)); 
    $oemEnc.GetString((byte()) 0xe9)

Θ

Note that the decoding to .NET strings (System.String) that invariably happens means that the characters are stored as UTF-16 code units in memory, essentially as (uint16) values underlying the System.Char instances that make up a .NET string. Such a code unit encodes a Unicode character either in full, or – for characters outside the so-called BMP (Basic Multilingual Plane) – half of a Unicode character, as part of a so-called surrogate pair.

In the case at hand this means that the Θ character is stored as a different code point, namely a Unicode code point: Θ (Greek capital letter theta, U+0398).


Solution:

PowerShell must be instructed what character encoding to use in this case, which can be done as follows:

PS> $msg = & { 
      # Save the original console output encoding...
      $prevEnc = (Console)::OutputEncoding
      # ... and (temporarily) set it to the active ANSI code page.
      # Note: In *Windows PowerShell* - only - (System.TextEncoding)::Default work as the RHS too.
      (Console)::OutputEncoding = (System.Text.Encoding)::GetEncoding((int) (Get-ItemPropertyValue HKLM:SYSTEMCurrentControlSetControlNlsCodePage ACP))

      # Now PowerShell will decode mosquitto_sub's output  correctly.
      mosquitto_sub -h test.mosquitto.org -t tofol/test

      # Restore the original encoding.
      (Console)::OutputEncoding = $prevEnc
    }; $msg

{ "label": "eé" }  # OK

Note: The Get-ItemPropertyValue cmdlet requires PowerShell version 5 or higher; in earlier version, either use (Console)::OutputEncoding = (System.TextEncoding)::Default or, if the code must also run in PowerShell (Core), (Console)::OutputEncoding = (System.Text.Encoding)::GetEncoding((int) (Get-ItemProperty HKLM:SYSTEMCurrentControlSetControlNlsCodePage ACP).ACP)


Helper function Invoke-WithEncoding can encapsulate this process for you. You can install it directly from a Gist as follows (I can assure you that doing so is safe, but you should always check):

# Download and define advanced function Invoke-WithEncoding in the current session.
irm https://gist.github.com/mklement0/ef57aea441ea8bd43387a7d7edfc6c19/raw/Invoke-WithEncoding.ps1 | iex

The workaround then simplifies to:

PS> Invoke-WithEncoding { mosquitto_sub -h test.mosquitto.org -t tofol/test } -Encoding Ansi -WindowsOnly

{ "label": "eé" }  # OK

A similar function focused on diagnostic output is Debug-NativeInOutput, discussed in this answer.


As an aside:

While PowerShell isn’t the problem here, it too can exhibit problematic character-encoding behavior.

GitHub issue #7233 proposes making PowerShell (Core) windows default to UTF-8 to minimize encoding problems with most modern command-line programs (it wouldn’t help with mosquitto_sub, however), and this comment fleshes out the proposal.


(1) Note that Python too exhibits this nonstandard behavior, but it offers UTF-8 encoding as an opt-in, either by setting environment variable PYTHONUTF8 to 1, or via the v3.7+ CLI option -X utf8 (must be specified case-exactly!).

dnd 5e – Does Iron Flask work on player characters?

The flask has no effect on most PCs while on the Material Plane

When you target a creature with the flask:

If the target is native to a plane of existence other than the one you’re on, the target must succeed on a DC 17 Wisdom saving throw or be trapped in the flask.

This effect only happens for creatures not native to the current plane. No effect is specified for a target that is native to the plane of existence, which means that if you are on the Material Plane and target a creature native to the Material Plane, the flask has no effect. The vast majority of playable races are native to the Material Plane, so they generally cannot be trapped by the flask under normal circumstances. However, there are exceptions, such as Eladrin (mechanically a sub-race of elves), who are “native to the Feywild”. An eladrin on the Material Plane can be affected by the flask.

However, if the party were to make an excursion to another plane, such as the Feywild, the PCs would indeed be vulnerable to the flask’s effect while they are not on the Material Plane. Conversely, an Eladrin PC would be immune to the flask while on the Feywild, since it is their native plane.

It may even be beneficial for a PC to use the flask on another PC under some rare circumstances, since the requirement to obey another PC’s orders might help override an enemy charm or mind control effect. This would obviously require quite a lot of trust, both in and out of character.

2013 – People Picker is not taking more than 256 Characters

I do have an InfoPath form in which I want to add a people Picker Field to validate a bulk of users that is normally more than 256 char , but I always get this alerting message (Item cannot be more than 256 characters)

I am looking for a solution avoiding any coding , however I tried a work around to feed the people picker by a multi line text field that accepts more than 256 char but it didn’t help in the validation option.

Recovering an old Multibit wallet file (76 characters long)

I have a wallet file from 2011 back when I used to play around with Bitcoin.

I used an old version of Multibit which has since long been unavailable.

My wallet looks like this:

# KEEP YOUR PRIVATE KEYS SAFE !
# Anyone who can read this file can spend your bitcoin.
#
# Format:
#   <Base58 encoded private key>(<whitespace>(<key createdAt>))
#
#   The Base58 encoded private keys are the same format as
#   produced by the Satoshi client/ sipa dumpprivkey utility.
#
#   Key createdAt is in UTC format as specified by ISO 8601
#   e.g: 2011-12-31T16:42:00Z . The century, 'T' and 'Z' are mandatory
#
U2FsdGVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXsnQhpZ6
 2013-10-30T20:52:01Z
# End of private keys

I managed to get a version of Multibit HD from the web archive but this doesn’t support this wallet.

I also tried using OpenSSL with the following command:

openssl enc -d -p -aes-256-cbc -md md5 -a -in C:keywallet.key.txt -out c:keywallet-decrypted.key.txt

This output a file which wasn’t correct and gave a bad decrypt error. I know the password for this file.

Does anyone know the correct method of decrypting this?

UPDATE: While I’m at it, I found a whole bunch more .key files. This one has a different format:

org.bitcoin.productionm!œ;€ò=°´zXXXXXXXXXXXXXXXXXÌñ9,o( 2D
䢦)5+¡XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE}Û@nŸé(2

ÐáXXXXR#
org.multibit.walletProtect.2 ZYour wallet description` 

categories – wordpress sub-category ( lowercase letters + non-latin characters ) = 404

If the sub-category’s slug is a combination of lowercase letters and Korean, page 404 appears.

1 : NGINX settings

location / {
    try_files $uri $uri/ /index.php?$args;
}

2 : WordPress – Permerlink settings

  • Custom: /%category%/%postname%/
  • Category Base:.

3 : WordPress – Yoast

  • Taxonomies > Category URLs ( Remove )

4 : Tested content

4-1 : In case of parent category ✅

  • mywebsite.com/한글 = 200
  • mywebsite.com/a한글 = 200
  • mywebsite.com/한글B = 200

4-2 : In case of post ✅

  • mywebsite.com/한글/post글 = 200 ( lowercase + non-latin )

4-3 : In case of child category ⚠️

  • mywebsite.com/한글/한글 = 200
  • mywebsite.com/한글/a한글 = 404 ❌
  • mywebsite.com/한글/한글b = 404 ❌
  • mywebsite.com/한글/C한글 = 200
  • mywebsite.com/한글/한글D = 200
  • mywebsite.com%2F%ED%95%9C%EA%B8%80%2Fa%ED%95%9C%EA%B8%80 = 200 ⭕️ ( /한글/a한글 : url encoded )
  • mywebsite.com/한글/A한글 = 200 ⭕️ ( /한글/a한글 : uppercase )

5 : Reference question

https://wordpress.stackexchange.com/questions/277401/arabic-characters-in-url-returns-404-error

I think it might be related to @user139986 ‘s answer.

I don’t know how to handle this problem .. 😭