Comments (3)
i am useing below dependency in server
import Koa from "koa";
import Router from "koa-router";
import bodyParser from "koa-bodyparser";
import json from "koa-json";
from koa.
Inside the middleware method
function sample(ctx) {
const {name} = ctx.query
const uint8 = Uint8Array.from([...name].map(c => c.codePointAt(0)))
const str = new TextDecoder().decode(uint8)
console.log({uint8, str})
// => { uint8: Uint8Array(6) [ 237, 149, 156, 234, 184, 128 ], str: '한글' }
ctx.body = str
}
Hope this helps! 😉
from koa.
thank you, i solve the problem below code
app.use(async (ctx: Koa.Context, next: Koa.Next) => {
const query = ctx.query;
for (const q in query) {
const queryValue = String(query[q]);
const queryCodePoint = Uint8Array.from([...queryValue]
.map(c => Number(c.codePointAt(0))));
const queryStr = new TextDecoder().decode(queryCodePoint);
query[q] = queryStr;
}
ctx.query = query;
await next();
})
your code was very helpful!
from koa.
Related Issues (20)
- [fix] Some things cannot be found in the database where condition search, unless the where condition search ID HOT 3
- koa 2.14.7 No generics,I want to be able to add generics HOT 1
- [feat] when will koa 3.0 be released? HOT 3
- Koa main website example code snippets disappear HOT 4
- [feat] Objects as middleware HOT 8
- [feat] Support Web (WHATWG) stream, Blob and Response HOT 6
- Consider alternatives to http-assert (including none at all) HOT 4
- [fix] Send response as buffer HOT 4
- async issue on app.listen(...) HOT 4
- [feat] Spanish translation for docs HOT 1
- Routing sucks, moving back to express. HOT 1
- [fix] ctx value persists to next request after mutating ctx object HOT 3
- if "\@" in url ,the redirect result doesn't match the host of the new URL() HOT 2
- [feat] Replace npm dependency "only" HOT 2
- [fix] Version 2.x introduced the URL object, which is not compatible with Node versions below 10.
- Client disconnect HOT 1
- [bug] TCP memory leak caused by aborted client connections when streaming data with node-fetch HOT 4
- Koa(2.15.3) Router Resolve the problem HOT 3
- Koa v3 Tracker HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa.