How to read and write files in UTF-8 format in win32

1, write data Initially, three bytes are written before writing data. BYTE btHead[] = {<!– –> 0xEF,0xBB,0xBF }; ::WriteFile(hFile, btHead, 3, & amp;dwWrite, 0); ::WriteFile(hFile, str, lstrlen(str)*sizeof(TCHAR), & amp;dwWrite, 0); The file style after writing is: The format is UTF-8, but there is a BOM behind it, and the Chinese characters are also garbled. Finally, […]

Solving UnicodeDecodeError: utf-8 codec cant decode byte 0xc2 in position 0: invalid continuation byt

Table of Contents Solving UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xc2 in position 0: invalid continuation byte error message reason solution Example 1: Read web page content and process it Example 2: Read text file and process it Solving UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xc2 in position 0: invalid continuation byte When processing text […]

[SWPUTF 2023 Autumn Freshman Competition]–Web Direction Detailed Writeup

Web colorful_snake Come play with Snake~ F12 to view the source code, you can see the this_is_real_flag function and find that it is unicode encoding Use website conversion to get flag One-click connection! Need again and again <?php highlight_file(__FILE__); error_reporting(0); $md5_1 = $_GET[‘md5_1’]; $md5_2 = $_GET[‘md5_2’]; $sha1_1 = $_GET[‘sha1_1’]; $sha1_2 = $_GET[‘sha1_2’]; $new_player =$_GET[‘new_player’]; if […]

Solving SyntaxError: Non-UTF-8 code starting with \xc0 in file but no encoding declared

Table of Contents Solving SyntaxError: Non-UTF-8 code starting with \xc0 in file but no encoding declared wrong reason Solution 1. Declare file encoding 2. Convert encoding 3. Remove non-UTF-8 characters 4. Use Unicode escaping Practical application scenarios What is UTF-8 encoding? Characteristics of UTF-8 encoding Application of UTF-8 encoding Solve SyntaxError: Non-UTF-8 code starting with […]

Forecast of capital inflow and outflow-understanding and running through the baseline

# Data format processing import pandas as pd import numpy as np # Temporal feature extraction import datetime # Ignore warnings: prevent them from interfering with program operation import warnings warnings.filterwarnings(‘ignore’) # Set the data set path path = ‘E:/Programming/Capital Inflow and Outflow Forecast/Purchase Redemption Data/’ # Extract timestamp: extract day, month, year, week from […]

Solving UnicodeDecodeError: utf-8 codec cant decode byte 0xd3 in position 238: invalid continuation b

Table of Contents Solving UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd3 in position 238: invalid continuation byte Method 1: Specify the correct encoding Method 2: Ignore error characters Method 3: Use other encodings to try decoding Method 4: Convert file encoding in conclusion Solving UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd3 in position 238: invalid […]

Solving UnicodeDecodeError: utf-8 codec cant decode byte 0xce in position 130: invalid continuation byt

Table of Contents Solving UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xce in position 130: invalid continuation byte wrong reason Solution 1. Specify the correct encoding method 2. Use error handling 3. Specify file encoding method Solve UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xce in position 130: invalid continuation byte In Python programming, we often encounter […]

Hadoop Mapper calculation and adjustment logic under various InputFormats

FileInputFormat Calculate splitSize goalSize total file size minSize configuration mapreduce.input.fileinputformat.split.minsize, default value 1 blockSize configuration dfs.block.size default value 128m computeSplitSize protected long computeSplitSize(long goalSize, long minSize, long blockSize) { return Math.max(minSize, Math.min(goalSize, blockSize)); } Calculate the number of MapTasks job.setLong(NUM_INPUT_FILES, files.length); long totalSize = 0; //compute total size for (FileStatus file: files) { // check […]

The relationship between various encoding formats (GB2312, GBK, GB18030, unicode, utf-8)

Common encoding formats for Chinese characters To display characters on the screen. The following steps are required: Make fonts corresponding to all characters. For example, what does the capital letter A look like. This appearance is the final graphic displayed on the screen, which is the character A we see. To encode all characters. For […]

SWPUTF 2022 Freshman Competition-WEB part of wp

Table of Contents ez_ez_php ez_ez_php(revenge) Wonderful MD5 1z_unserialize numgame where_am_i ez_ez_unserialize js_sign xff webdog1__start ez_sql funny_php funny_web ez_1zpop Ez_upload file_master Power! ez_ez_php source code: <?php error_reporting(0); if (isset($_GET[‘file’])) { if ( substr($_GET[“file”], 0, 3) === “php” ) { echo “Nice!!!”; include($_GET[“file”]); } else { echo “Hacker!!”; } }else { highlight_file(__FILE__); } //flag.php The file contains […]