Garbled utf-8 QString when reading network reply - qt

I am building a BlackBerry 10 application and I am using the QT libraries. However I got some character encoding issues and I was wondering if you might have a clue as how to solve this.
I have the following data that gets send to me via a web service.
{"title":"Seconde Guerre mondiale - Wikipédia","content":"Théâtre européen L’Europe au 1er septembre 1939 Après s’être assuré de ne pas risquer une guerre avec l’URSS en signant le Pacte germano-soviétique, Hitler lance ses armées sur la Pologne, l...","favicon":"http://fr.m.wikipedia.org//bits.wikimedia.org/favicon/wikipedia.ico"}
If I wireshark it, the raw data is:
[truncated] {"title":"Seconde Guerre mondiale - Wikip\303\251dia","content":"Th\303\251\303\242tre
However when I parse this using the following code:
void WebpageFetcher::onPageRequestFinished(QNetworkReply* networkReply)
{
qDebug() << "WebpageFetcher:: onPageRequestFinished";
QByteArray content = networkReply->readAll();
qDebug() << QString::fromUtf8(content.data(), content.size());
}
I get this result:
"{"title":"Seconde Guerre mondiale - Wikipédia","content":"Théâtre européen L’Europe au 1er septembre 1939 Après s’être assuré de ne pas risquer une guerre avec l’URSS en signant le Pacte germano-soviétique, Hitler lance ses armées sur la Pologne, l...","favicon":"http://fr.m.wikipedia.org//bits.wikimedia.org/favicon/wikipedia.ico"}"
Not exactly what I am looking for. Does anyone have a clue? My browsers seem to be able to interpret the characters in this JSON reply perfectly.

Related

How to move Google Drive folder into specific alphabetic folder within make.com

I have very limited coding skills so I used make.com for automation purpose. I have automated our client onboarding process but there are two things I cant achieve.
When a new client is onboarded, a new folder in our google drive is created. this folder is named "client name - city". Our client folders are organized in folders "drive/client/a" ; "drive/client/b" etc. What I want to achieve, is that the folder gets moved into the right folder (Example: Client Folder is "Tesla Inc" it should be moved into "drive/client/t"
I have tried ChatGPT and this is the script it sent me:
# Zielordner basierend auf dem Anfangsbuchstaben des Ordners bestimmen
destination_folders = {
'A': '456def', # ID des Ordners für den Buchstaben "A"
'B': '789ghi', # ID des Ordners für den Buchstaben "B"
# ... weitere Einträge für alle Buchstaben des Alphabets ...
}
first_letter = folder_name[0]
destination_folder_id = destination_folders.get(first_letter, None)
if destination_folder_id is None:
print(f'Kein Zielordner gefunden für den Anfangsbuchstaben {first_letter}. Der Ordner wird nicht verschoben.')
else:
# Ordner in Zielordner verschieben
file_metadata = {
'parents': [destination_folder_id]
}
try:
result = drive_service.files().update(fileId=new_folder_id, body=file_metadata).execute()
print(f'Ordner {new_folder_id} wurde in den Ordner {destination_folder_id} verschoben.')
except HttpError as error:
print(f'Fehler beim Verschieben des Ordners: {error}')
I have already created an google sheet with all IDs to every letter of the alphabet. This can easily be implemented into the script, but Im not sure, how to solve this problem and move to the next step. Can anyone help?
Cheers
Ismar
I have tried several modules within make.com but none of them had the functionality I needed. I also tried to perform a google sheet function to solve this, but always ended up not knowing how to implement this into make.com

Rmarkdown won't compile to html or pdf

I have a problem when compiling my rmarkdown to html. When I compile i receive the next message:
[WARNING] This document format requires a nonempty <title> element.
Please specify either 'title' or 'pagetitle' in the metadata,
e.g. by using --metadata pagetitle="..." on the command line.
Falling back to '1570037.knit'
Output created: 1570037.html
Warning messages:
1: In readLines(con, warn = FALSE) :
entrada inválida encontrada en la conexión de entrada '1570037.Rmd'
2: In xfun::read_utf8(input) :
The file 1570037.Rmd is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 2, 3, 29, 91, 92, 95, ...
3: In readLines(con, warn = FALSE) :
entrada inválida encontrada en la conexión de entrada '1570037.knit.md'
4: In readLines(con, warn = FALSE) :
entrada inválida encontrada en la conexión de entrada '1570037.knit.md'
And I cant compile the script. Does someone know how to fix this?
First, try to set the header like this:
---
title: "Your Title"
output: html_document
---
Then, try to render the file in your R console like this:
rmarkdown::render('your_file.Rmd', encoding='UTF-8')

set_locale in wordpress - woocommerce - stripe

Hello
my locale setting work everywhere except in stripe geteway plugin ( have asked stripe and woocommerce support : no solution )
detail of the probleme/bug here
https://github.com/woocommerce/woocommerce-gateway-stripe/issues/701
new info for this
testing this morning with the hook "wc_stripe_localized_messages"
add_filter("wc_stripe_localized_messages", function($arr_def){
$lang = WPTBASE::$theme_var["lang"];
WPTBASE::init_lang( $lang ); // this init lang and local
$wp_locale = get_locale(); // wp locale val
print "<pre>";
print "theme locale = " . WPTBASE::$theme_var["local"] . "\n";
print "wp locale = " . $wp_locale . "\n";
print $lang . "\n";
print $arr_def["invalid_number"];
print "\n";
print __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' );
print "</pre>";
return $arr_def;
});
this ouput at the top of the checkout page
https://www.support-rack.com/sr_2018/ca/eng/checkout/
this :
theme locale = en_CA
wp locale = en_CA
eng
Le numéro de la carte de paiement n’est pas un numéro de carte de paiement valide.
Le numéro de la carte de paiement n’est pas un numéro de carte de paiement valide.
the wordpress locale is en_CA
but the __() ouput is french ?
help !
Resolve !
Wordpress french locale file is 'fr_CA' / canada
the stripe french locale file is fr_FR / france
I'm using fr_CA .....
details / details / details
this was a friday exercice

symfony: Format date in assert message

I have assertion on my entity to validate dates. It's work well, but the outuput is formated whith time. I need only the date. (The text is in french)
My entity :
/**
* #var \DateTime
* #Assert\DateTime(format="d/m/Y")
* #Assert\LessThanOrEqual(
* value="-2 days",
* message="rapports.max_date"
* )
*/
protected $dateDebut;
My translation file :
max_date: 'La date saisie doit être inférieur ou égale au {{ compared_value }}.'
That output is "La date saisie doit être supérieur ou égale au 1 janv. 2015 à 01:00.". I want "La date saisie doit être supérieur ou égale au 01/001/2015."
I want to format the 'compared_value'. WHo can I do that ?
Maybe use the date_format filter:
max_date: 'La date saisie doit être inférieur ou égale au {{ compared_value | date_format('Y-m-d') }}.'
You can do the following:
Write a service and make it globally available to the twig engine.
This service has to define a public function that takes the compared_value, parses the wrongly formatted date, and outputs the correctly formatted one.
So:
class MyService
{
public function parse($compared_value) {
return date_format('Y-m-d', strtotime($compared_value));
}
}
in config.yml
twig:
globals:
my_service: '#my_service'
services:
my_service:
class: AppBundle\Service\MyService
and finally
max_date: 'La date saisie doit être inférieur ou égale au {{ my_service.parse(compared_value) }}.'

GenemuFormBundle not translating "The captcha is not valid" To locale language (fr)?

All in the title, and in the validators.fr.yml all is good, this is it:
The captcha is invalid.: Le captcha est invalide.
genemu_form:
recaptcha:
incorrect-captcha-sol: Le captcha n'est pas valide.
invalid-site-private-key: La clé privée est invalide.

Resources