问题描述
我的简单代码在输出时日语字符没有问题,但是由于某种原因,它不能正确输入,是否缺少某些东西?
btnShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
searchID = txtid.getText().toString().trim();
DatabaseReference readRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference dref = readRef.child("Student");
Query query = dref.orderByChild("id").equalTo(searchID);
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.hasChildren()){
txtID.setText((dataSnapshot.child("id").getValue().toString()));
txtName.setText((dataSnapshot.child("name").getValue().toString()));
txtAdd.setText((dataSnapshot.child("address").getValue().toString()));
txtConNo.setText((dataSnapshot.child("conNo").getValue().toString()));
}
else
Toast.makeText(getApplicationContext(),"No Source to Display",Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
});
解决方法
此代码在Windows 10命令提示符下对我有用。关于_O_
标志的解释不多...
#include <fcntl.h>
#include <io.h>
#include <string>
#include <iostream>
using namespace std;
int main()
{
_setmode(_fileno(stdout),_O_U16TEXT); // _O_WTEXT also worked
_setmode(_fileno(stdin),_O_WTEXT); // only _O_WTEXT worked
wstring s = L"こんにちは,世界!\nHello,World!";
wcout << s << endl;
wstring test;
getline(wcin,test);
wcout << test << endl;
return 0;
}
输出:
C:\>test
こんにちは,世界!
Hello,World!
你好马克! << input line
你好马克!